diff --git a/examples/census/app.ddlog b/examples/census/app.ddlog index bbcdc5bea..a9fec4a6f 100644 --- a/examples/census/app.ddlog +++ b/examples/census/app.ddlog @@ -32,27 +32,35 @@ rich(id) = if income_bracket = ">50K" then TRUE else FALSE end ############# CATEGORICAL ############### +@name("workclass") @weight(workclass) rich(id) :- adult(id, _, workclass, _, _, _, _, _, _, _, _, _, _, _, _, income_bracket). +@name("education") @weight(education) rich(id) :- adult(id, _, _, _, education, _, _, _, _, _, _, _, _, _, _, income_bracket). +@name("marital_status") @weight(marital_status) rich(id) :- adult(id, _, _, _, _, _, marital_status, _, _, _, _, _, _, _, _, income_bracket). +@name("occupation") @weight(occupation) rich(id) :- adult(id, _, _, _, _, _, _, occupation, _, _, _, _, _, _, _, income_bracket). +@name("relationship") @weight(relationship) rich(id) :- adult(id, _, _, _, _, _, _, _, relationship, _, _, _, _, _, _, income_bracket). +@name("race") @weight(race) rich(id) :- adult(id, _, _, _, _, _, _, _, _, race, _, _, _, _, _, income_bracket). +@name("gender") @weight(gender) rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, gender, _, _, _, _, income_bracket). +@name("native_country") @weight(native_country) rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, _, _, _, _, native_country, income_bracket). @@ -60,22 +68,27 @@ rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, _, _, _, _, native_country, inc ############# CONTINUOUS ############### +@name("age") @weight("") @feature_value(age) rich(id) :- adult(id, age, _, _, _, _, _, _, _, _, _, _, _, _, _, income_bracket). +@name("education_num") @weight("") @feature_value(education_num) rich(id) :- adult(id, _, _, _, _, education_num, _, _, _, _, _, _, _, _, _, income_bracket). +@name("capital_gain") @weight("") @feature_value(capital_gain) rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, _, capital_gain, _, _, _, income_bracket). +@name("capital_loss") @weight("") @feature_value(capital_loss) rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, _, _, capital_loss, _, _, income_bracket). +@name("hours_per_week") @weight("") @feature_value(hours_per_week) rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, _, _, _, hours_per_week, _, income_bracket). @@ -84,6 +97,7 @@ rich(id) :- adult(id, _, _, _, _, _, _, _, _, _, _, _, _, hours_per_week, _, inc ############# BUCKETIZED ############### +@name("age_bucket") @weight(width_bucket(age, 18, 88, 10)) rich(id) :- adult(id, age, _, _, _, _, _, _, _, _, _, _, _, _, _, income_bracket). @@ -92,9 +106,11 @@ rich(id) :- adult(id, age, _, _, _, _, _, _, _, _, _, _, _, _, _, income_bracket ############# COMPOSITE ############### +@name("education X occupation") @weight(education, occupation) rich(id) :- adult(id, _, _, _, education, _, occupation, _, _, _, _, _, _, _, _, income_bracket). +@name("race X occupation X age_bucket") @weight(race, occupation, width_bucket(age, 18, 88, 10)) rich(id) :- adult(id, age, _, _, _, _, _, occupation, _, race, _, _, _, _, _, income_bracket). diff --git a/examples/chunking/app.ddlog b/examples/chunking/app.ddlog index 16ff78d4c..0320639f8 100644 --- a/examples/chunking/app.ddlog +++ b/examples/chunking/app.ddlog @@ -38,20 +38,24 @@ chunk(s, word, tag) = ( # unigram features ############################################################### +@name("current word") @weight(tag, word) chunk(s, w, tag) :- words(s, w, word, pos, _). +@name("current pos tag") @weight(tag, pos) chunk(s, w, tag) :- words(s, w, word, pos, _). +@name("current and next pos") @weight(tag, pos1, pos2) chunk(s, w1, tag) :- w2 = w1 + 1, words(s, w1, word1, pos1, _), words(s, w2, word2, pos2, _). +@name("current and prev pos") @weight(tag, pos1, pos2) chunk(s, w2, tag) :- w2 = w1 + 1, @@ -61,9 +65,11 @@ chunk(s, w2, tag) :- # bigram features ############################################################### +@name("linear chain") @weight(tag1, tag2) chunk(s, w1, tag1) ^ chunk(s, w2, tag2) :- w2 = w1 + 1. +@name("linear chain by pos") @weight(tag1, tag2, pos1, pos2) chunk(s, w1, tag1) ^ chunk(s, w2, tag2) :- w2 = w1 + 1, @@ -73,6 +79,7 @@ chunk(s, w1, tag1) ^ chunk(s, w2, tag2) :- # word embedding features ############################################################### +@name("word embedding") @weight(tag, k) @feature_value(vec[k]) chunk(s, w, tag) :-