treat 1.2.0 → 2.0.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -2
- data/README.md +12 -21
- data/lib/treat/autoload.rb +44 -0
- data/lib/treat/config/config.rb +38 -0
- data/lib/treat/config/configurable.rb +51 -0
- data/lib/treat/config/data/config.rb +50 -0
- data/lib/treat/config/data/core.rb +52 -0
- data/lib/treat/config/data/databases.rb +10 -0
- data/lib/treat/config/data/entities.rb +15 -0
- data/lib/treat/config/data/languages/agnostic.rb +31 -0
- data/lib/treat/config/{languages → data/languages}/arabic.rb +0 -0
- data/lib/treat/config/{languages → data/languages}/chinese.rb +0 -0
- data/lib/treat/config/{languages → data/languages}/dutch.rb +1 -1
- data/lib/treat/config/data/languages/english.rb +95 -0
- data/lib/treat/config/data/languages/french.rb +148 -0
- data/lib/treat/config/data/languages/german.rb +135 -0
- data/lib/treat/config/{languages → data/languages}/greek.rb +1 -1
- data/lib/treat/config/data/languages/italian.rb +162 -0
- data/lib/treat/config/data/languages/polish.rb +11 -0
- data/lib/treat/config/{languages → data/languages}/portuguese.rb +1 -1
- data/lib/treat/config/{languages → data/languages}/russian.rb +1 -1
- data/lib/treat/config/data/languages/spanish.rb +291 -0
- data/lib/treat/config/data/languages/swedish.rb +289 -0
- data/lib/treat/config/data/libraries.rb +12 -0
- data/lib/treat/config/data/linguistics.rb +44 -0
- data/lib/treat/config/data/tags.rb +328 -0
- data/lib/treat/config/{workers → data/workers}/extractors.rb +2 -10
- data/lib/treat/config/{workers → data/workers}/formatters.rb +0 -0
- data/lib/treat/config/{workers → data/workers}/inflectors.rb +0 -0
- data/lib/treat/config/{workers → data/workers}/learners.rb +0 -0
- data/lib/treat/config/{workers → data/workers}/lexicalizers.rb +4 -3
- data/lib/treat/config/{workers → data/workers}/processors.rb +3 -3
- data/lib/treat/config/{workers → data/workers}/retrievers.rb +0 -0
- data/lib/treat/config/importable.rb +31 -0
- data/lib/treat/config/paths.rb +23 -0
- data/lib/treat/config/tags.rb +37 -0
- data/lib/treat/core/dsl.rb +55 -0
- data/lib/treat/{installer.rb → core/installer.rb} +10 -12
- data/lib/treat/core/server.rb +40 -0
- data/lib/treat/entities/entities.rb +101 -0
- data/lib/treat/entities/{abilities/doable.rb → entity/applicable.rb} +5 -3
- data/lib/treat/entities/{abilities → entity}/buildable.rb +118 -63
- data/lib/treat/entities/{abilities → entity}/checkable.rb +2 -2
- data/lib/treat/entities/{abilities → entity}/comparable.rb +6 -6
- data/lib/treat/entities/{abilities → entity}/countable.rb +2 -1
- data/lib/treat/entities/entity/debuggable.rb +86 -0
- data/lib/treat/entities/{abilities → entity}/delegatable.rb +16 -26
- data/lib/treat/entities/{abilities → entity}/exportable.rb +2 -2
- data/lib/treat/entities/{abilities → entity}/iterable.rb +4 -16
- data/lib/treat/entities/{abilities → entity}/magical.rb +22 -17
- data/lib/treat/entities/entity/registrable.rb +36 -0
- data/lib/treat/entities/{abilities → entity}/stringable.rb +18 -15
- data/lib/treat/entities/entity.rb +86 -77
- data/lib/treat/exception.rb +3 -0
- data/lib/treat/helpers/hash.rb +29 -0
- data/lib/treat/helpers/help.rb +35 -0
- data/lib/treat/helpers/object.rb +55 -0
- data/lib/treat/helpers/string.rb +124 -0
- data/lib/treat/{core → learning}/data_set.rb +11 -11
- data/lib/treat/{core → learning}/export.rb +3 -3
- data/lib/treat/{core → learning}/problem.rb +26 -16
- data/lib/treat/{core → learning}/question.rb +5 -9
- data/lib/treat/loaders/linguistics.rb +8 -9
- data/lib/treat/loaders/stanford.rb +5 -11
- data/lib/treat/modules.rb +33 -0
- data/lib/treat/proxies/array.rb +27 -0
- data/lib/treat/proxies/language.rb +47 -0
- data/lib/treat/proxies/number.rb +18 -0
- data/lib/treat/proxies/proxy.rb +25 -0
- data/lib/treat/proxies/string.rb +18 -0
- data/lib/treat/version.rb +10 -1
- data/lib/treat/{workers.rb → workers/categorizable.rb} +18 -19
- data/lib/treat/workers/extractors/keywords/tf_idf.rb +11 -11
- data/lib/treat/workers/extractors/language/what_language.rb +8 -6
- data/lib/treat/workers/extractors/name_tag/stanford.rb +10 -4
- data/lib/treat/workers/extractors/similarity/levenshtein.rb +36 -0
- data/lib/treat/workers/extractors/similarity/tf_idf.rb +27 -0
- data/lib/treat/workers/extractors/tf_idf/native.rb +4 -4
- data/lib/treat/workers/extractors/time/chronic.rb +2 -4
- data/lib/treat/workers/extractors/time/nickel.rb +19 -20
- data/lib/treat/workers/extractors/time/ruby.rb +2 -1
- data/lib/treat/workers/extractors/topic_words/lda.rb +12 -12
- data/lib/treat/workers/extractors/topics/reuters.rb +9 -13
- data/lib/treat/workers/formatters/readers/autoselect.rb +1 -1
- data/lib/treat/workers/formatters/readers/image.rb +19 -9
- data/lib/treat/workers/formatters/readers/odt.rb +2 -1
- data/lib/treat/workers/formatters/readers/pdf.rb +20 -3
- data/lib/treat/workers/formatters/readers/xml.rb +0 -1
- data/lib/treat/workers/formatters/serializers/mongo.rb +10 -20
- data/lib/treat/workers/formatters/serializers/xml.rb +17 -26
- data/lib/treat/workers/formatters/serializers/yaml.rb +5 -4
- data/lib/treat/workers/formatters/unserializers/mongo.rb +4 -4
- data/lib/treat/workers/formatters/unserializers/xml.rb +3 -4
- data/lib/treat/workers/formatters/unserializers/yaml.rb +3 -4
- data/lib/treat/workers/formatters/visualizers/dot.rb +1 -0
- data/lib/treat/workers/formatters/visualizers/standoff.rb +2 -3
- data/lib/treat/workers/formatters/visualizers/tree.rb +2 -3
- data/lib/treat/workers/{group.rb → groupable.rb} +9 -9
- data/lib/treat/workers/inflectors/cardinalizers/linguistics.rb +1 -3
- data/lib/treat/workers/inflectors/conjugators/linguistics.rb +5 -7
- data/lib/treat/workers/inflectors/declensors/english.rb +13 -20
- data/lib/treat/workers/inflectors/declensors/linguistics.rb +29 -28
- data/lib/treat/workers/inflectors/ordinalizers/linguistics.rb +0 -2
- data/lib/treat/workers/inflectors/stemmers/porter.rb +8 -10
- data/lib/treat/workers/inflectors/stemmers/porter_c.rb +7 -7
- data/lib/treat/workers/inflectors/stemmers/uea.rb +3 -8
- data/lib/treat/workers/learners/classifiers/id3.rb +17 -14
- data/lib/treat/workers/learners/classifiers/linear.rb +15 -27
- data/lib/treat/workers/learners/classifiers/mlp.rb +32 -19
- data/lib/treat/workers/learners/classifiers/svm.rb +28 -21
- data/lib/treat/workers/lexicalizers/categorizers/from_tag.rb +19 -3
- data/lib/treat/workers/lexicalizers/sensers/wordnet.rb +15 -7
- data/lib/treat/workers/lexicalizers/taggers/brill/patch.rb +4 -1
- data/lib/treat/workers/lexicalizers/taggers/brill.rb +8 -19
- data/lib/treat/workers/lexicalizers/taggers/lingua.rb +4 -15
- data/lib/treat/workers/lexicalizers/taggers/stanford.rb +22 -13
- data/lib/treat/workers/processors/chunkers/autoselect.rb +2 -3
- data/lib/treat/workers/processors/chunkers/html.rb +1 -6
- data/lib/treat/workers/processors/parsers/enju.rb +2 -4
- data/lib/treat/workers/processors/parsers/stanford.rb +13 -7
- data/lib/treat/workers/processors/segmenters/punkt.rb +25 -11
- data/lib/treat/workers/processors/segmenters/scalpel.rb +20 -0
- data/lib/treat/workers/processors/segmenters/srx.rb +42 -0
- data/lib/treat/workers/processors/segmenters/stanford.rb +5 -5
- data/lib/treat/workers/processors/segmenters/tactful.rb +21 -11
- data/lib/treat/workers/processors/tokenizers/ptb.rb +40 -30
- data/lib/treat/workers/processors/tokenizers/punkt.rb +14 -19
- data/lib/treat/workers/processors/tokenizers/stanford.rb +38 -22
- data/lib/treat/workers/retrievers/indexers/ferret.rb +6 -3
- data/lib/treat/workers/retrievers/searchers/ferret.rb +2 -2
- data/lib/treat/workers/workers.rb +6 -0
- data/lib/treat.rb +18 -32
- data/models/MANIFEST +1 -0
- data/spec/core/data_set.rb +174 -0
- data/spec/core/export.rb +52 -0
- data/spec/core/problem.rb +144 -0
- data/spec/core/question.rb +52 -0
- data/spec/{collection.rb → entities/collection.rb} +20 -35
- data/spec/{document.rb → entities/document.rb} +3 -54
- data/spec/{entity.rb → entities/entity.rb} +10 -9
- data/spec/entities/phrase.rb +33 -0
- data/spec/{token.rb → entities/token.rb} +0 -57
- data/spec/entities/word.rb +3 -0
- data/spec/{zone.rb → entities/zone.rb} +0 -26
- data/spec/helper.rb +116 -32
- data/spec/sandbox.rb +258 -25
- data/spec/treat.rb +26 -34
- data/spec/workers/agnostic.rb +137 -0
- data/spec/workers/english.rb +194 -0
- data/spec/workers/examples/english/economist/hungarys_troubles.txt +46 -0
- data/spec/workers/examples/english/economist/saving_the_euro.odt +0 -0
- data/spec/{samples → workers/examples/english}/mathematicians/archimedes.abw +0 -0
- data/spec/{samples → workers/examples/english}/mathematicians/euler.html +0 -0
- data/spec/{samples → workers/examples/english}/mathematicians/gauss.pdf +0 -0
- data/spec/{samples → workers/examples/english}/mathematicians/leibniz.txt +0 -0
- data/spec/{samples → workers/examples/english}/mathematicians/newton.doc +0 -0
- data/spec/workers/examples/english/phrase.xml +5 -0
- data/spec/workers/examples/english/test.txt +1 -0
- data/spec/workers/language.rb +280 -0
- data/spec/workers.rb +28 -0
- metadata +122 -105
- data/lib/treat/config/core/acronyms.rb +0 -5
- data/lib/treat/config/core/encodings.rb +0 -8
- data/lib/treat/config/core/entities.rb +0 -2
- data/lib/treat/config/core/language.rb +0 -3
- data/lib/treat/config/core/paths.rb +0 -8
- data/lib/treat/config/core/syntax.rb +0 -1
- data/lib/treat/config/core/verbosity.rb +0 -1
- data/lib/treat/config/databases/default.rb +0 -1
- data/lib/treat/config/databases/mongo.rb +0 -1
- data/lib/treat/config/languages/agnostic.rb +0 -34
- data/lib/treat/config/languages/english.rb +0 -60
- data/lib/treat/config/languages/french.rb +0 -18
- data/lib/treat/config/languages/german.rb +0 -18
- data/lib/treat/config/languages/italian.rb +0 -12
- data/lib/treat/config/languages/polish.rb +0 -12
- data/lib/treat/config/languages/spanish.rb +0 -12
- data/lib/treat/config/languages/swedish.rb +0 -12
- data/lib/treat/config/libraries/punkt.rb +0 -1
- data/lib/treat/config/libraries/reuters.rb +0 -1
- data/lib/treat/config/libraries/stanford.rb +0 -1
- data/lib/treat/config/linguistics/categories.rb +0 -4
- data/lib/treat/config/linguistics/punctuation.rb +0 -33
- data/lib/treat/config/tags/aligned.rb +0 -221
- data/lib/treat/config/tags/enju.rb +0 -71
- data/lib/treat/config/tags/paris7.rb +0 -17
- data/lib/treat/config/tags/ptb.rb +0 -15
- data/lib/treat/config/workers/list.rb +0 -1
- data/lib/treat/config.rb +0 -135
- data/lib/treat/core.rb +0 -5
- data/lib/treat/entities/abilities/copyable.rb +0 -47
- data/lib/treat/entities/abilities/debuggable.rb +0 -83
- data/lib/treat/entities/abilities/registrable.rb +0 -46
- data/lib/treat/entities/collection.rb +0 -40
- data/lib/treat/entities/document.rb +0 -10
- data/lib/treat/entities/group.rb +0 -18
- data/lib/treat/entities/section.rb +0 -13
- data/lib/treat/entities/token.rb +0 -47
- data/lib/treat/entities/zone.rb +0 -12
- data/lib/treat/entities.rb +0 -6
- data/lib/treat/helpers/didyoumean.rb +0 -57
- data/lib/treat/helpers/escaping.rb +0 -15
- data/lib/treat/helpers/formatting.rb +0 -41
- data/lib/treat/helpers/objtohash.rb +0 -8
- data/lib/treat/helpers/platform.rb +0 -15
- data/lib/treat/helpers/reflection.rb +0 -17
- data/lib/treat/helpers/temporary.rb +0 -27
- data/lib/treat/helpers/verbosity.rb +0 -19
- data/lib/treat/helpers.rb +0 -5
- data/lib/treat/loaders.rb +0 -10
- data/lib/treat/proxies.rb +0 -106
- data/lib/treat/workers/formatters/unserializers/autoselect.rb +0 -17
- data/lib/treat/workers/inflectors/declensors/active_support.rb +0 -31
- data/lib/treat/workers/processors/tokenizers/tactful.rb +0 -68
- data/spec/core.rb +0 -441
- data/spec/phrase.rb +0 -112
- data/spec/word.rb +0 -111
@@ -0,0 +1,328 @@
|
|
1
|
+
{
|
2
|
+
aligned: {
|
3
|
+
tag_sets: [
|
4
|
+
:claws_c5, :brown, :penn,
|
5
|
+
:stutgart, :chinese, :paris7
|
6
|
+
],
|
7
|
+
phrase_tags: [
|
8
|
+
'Adjectival phrase', ['', '', 'ADJP', '', '', 'AP'],
|
9
|
+
'Adverbial phrase', ['', '', 'ADVP', '', '', 'AdP'],
|
10
|
+
'Conjunction phrase', ['', '', 'CONJP', '', '', 'Ssub'],
|
11
|
+
'Fragment', ['', '', 'FRAG', '', '', ''],
|
12
|
+
'Interjectional phrase', ['', '', 'INTJ', '', '', ''],
|
13
|
+
'List marker', ['', '', 'LST', '', '', ''],
|
14
|
+
'Not a phrase', ['', '', 'NAC', '', '', ''],
|
15
|
+
'Noun phrase', ['', '', 'NP', '', '', 'NP'],
|
16
|
+
'Verbal nucleus', ['', '', '', '', '', 'VN'],
|
17
|
+
'Head of noun phrase', ['', '', 'NX', '', '', ''],
|
18
|
+
'Prepositional phrase', ['', '', 'PP', '', '', 'PP'],
|
19
|
+
'Parenthetical', ['', '', 'PRN', '', '', ''],
|
20
|
+
'Particle', ['', '', 'PRT', '', '', ''],
|
21
|
+
'Participial phrase', ['', '', '', '', '', 'VPart'],
|
22
|
+
'Quantifier phrase', ['', '', 'QP', '', '', ''],
|
23
|
+
'Relative clause', ['', '', 'RRC', '', '', 'Srel'],
|
24
|
+
'Coordinated phrase', ['', '', 'UCP', '', '', 'COORD'],
|
25
|
+
'Infinitival phrase', ['', '', '', '', '', 'VPinf'],
|
26
|
+
'Verb phrase', ['', '', 'VP', '', '', ''],
|
27
|
+
'Inverted yes/no question', ['', '', 'SQ', '', '', ''],
|
28
|
+
'Wh adjective phrase', ['', '', 'WHADJP', '', '', ''],
|
29
|
+
'Wh adverb phrase', ['', '', 'WHAVP', '', '', ''],
|
30
|
+
'Wh noun phrase', ['', '', 'WHNP', '', '', ''],
|
31
|
+
'Wh prepositional phrase', ['', '', 'WHPP', '', '', ''],
|
32
|
+
'Unknown', ['', '', 'X', '', '', ''],
|
33
|
+
'Phrase', ['', '', 'P', '', '', 'Sint'],
|
34
|
+
'Sentence', ['', '', 'S', '', '', 'SENT'],
|
35
|
+
'Phrase', ['', '', 'SBAR', '', '', ''] # Fix
|
36
|
+
],
|
37
|
+
word_tags: [
|
38
|
+
|
39
|
+
# Aligned tags for the Claws C5, Brown and Penn tag sets.
|
40
|
+
'Adjective', ['AJ0', 'JJ', 'JJ', '', 'JJ', 'A'],
|
41
|
+
'Adjective', ['AJ0', 'JJ', 'JJ', '', 'JJ', 'ADJ'],
|
42
|
+
'Ajective, adverbial or predicative', ['', '', '', 'ADJD', '', 'ADJ'],
|
43
|
+
'Adjective, attribute', ['', '', '', 'ADJA', 'VA', 'ADJ'],
|
44
|
+
'Adjective, ordinal number', ['ORD', 'OD', 'JJ', '', 'OD', 'ADJ'],
|
45
|
+
'Adjective, comparative', ['AJC', 'JJR', 'JJR', 'KOKOM', '', 'ADJ'],
|
46
|
+
'Adjective, superlative', ['AJS', 'JJT', 'JJS', '', 'JJ', 'ADJ'],
|
47
|
+
'Adjective, superlative, semantically', ['AJ0', 'JJS', 'JJ', '', '', 'ADJ'],
|
48
|
+
'Adjective, cardinal number', ['CRD', 'CD', 'CD', 'CARD', 'CD', 'ADJ'],
|
49
|
+
'Adjective, cardinal number, one', ['PNI', 'CD', 'CD', 'CARD', 'CD', 'ADJ'],
|
50
|
+
|
51
|
+
'Adverb', ['AV0', 'RB', 'RB', 'ADV', 'AD', 'ADV'],
|
52
|
+
'Adverb, negative', ['XX0', '*', 'RB', 'PTKNEG', '', 'ADV'],
|
53
|
+
'Adverb, comparative', ['AV0', 'RBR', 'RBR', '', 'AD', 'ADV'],
|
54
|
+
'Adverb, superlative', ['AV0', 'RBT', 'RBS', '', 'AD', 'ADV'],
|
55
|
+
'Adverb, particle', ['AVP', 'RP', 'RP', '', '', 'ADV'],
|
56
|
+
'Adverb, question', ['AVQ', 'WRB', 'WRB', '', 'AD', 'ADV'],
|
57
|
+
'Adverb, degree & question', ['AVQ', 'WQL', 'WRB', '', 'ADV'],
|
58
|
+
'Adverb, degree', ['AV0', 'QL', 'RB', '', '', 'ADV'],
|
59
|
+
'Adverb, degree, postposed', ['AV0', 'QLP', 'RB', '', '', 'ADV'],
|
60
|
+
'Adverb, nominal', ['AV0', 'RN', 'RB', 'PROP', '', 'ADV'],
|
61
|
+
'Adverb, pronominal', ['', '', '', '', 'PROP', '', 'ADV'],
|
62
|
+
|
63
|
+
'Conjunction, coordination', ['CJC', 'CC', 'CC', 'KON', 'CC', 'COOD'],
|
64
|
+
'Conjunction, coordination, and', ['CJC', 'CC', 'CC', 'KON', 'CC', 'ET'],
|
65
|
+
'Conjunction, subordination', ['CJS', 'CS', 'IN', 'KOUS', 'CS', 'CONJ'],
|
66
|
+
'Conjunction, subordination with to and infinitive', ['', '', '', 'KOUI', '', ''],
|
67
|
+
'Conjunction, complementizer, that', ['CJT', 'CS', 'IN', '', '', 'C'],
|
68
|
+
|
69
|
+
'Determiner', ['DT0', 'DT', 'DT', '', 'DT', 'D'],
|
70
|
+
'Determiner, pronoun', ['DT0', 'DTI', 'DT', '', '', 'D'],
|
71
|
+
'Determiner, pronoun, plural', ['DT0', 'DTS', 'DT', '', '', 'D'],
|
72
|
+
'Determiner, prequalifier', ['DT0', 'ABL', 'DT', '', '', 'D'],
|
73
|
+
'Determiner, prequantifier', ['DT0', 'ABN', 'PDT', '', 'DT', 'D'],
|
74
|
+
'Determiner, pronoun or double conjunction', ['DT0', 'ABX', 'PDT', '', '', 'D'],
|
75
|
+
'Determiner, pronoun or double conjunction', ['DT0', 'DTX', 'DT', '', '', 'D'],
|
76
|
+
'Determiner, article', ['AT0', 'AT', 'DT', 'ART', '', 'D'],
|
77
|
+
'Determiner, postdeterminer', ['DT0', 'AP', 'DT', '', '', 'D'],
|
78
|
+
'Determiner, possessive', ['DPS', 'PP$', 'PRP$', '', '', 'D'],
|
79
|
+
'Determiner, possessive, second', ['DPS', 'PP$', 'PRPS', '', '', 'D'],
|
80
|
+
'Determiner, question', ['DTQ', 'WDT', 'WDT', '', 'DT', 'D'],
|
81
|
+
'Determiner, possessive & question', ['DTQ', 'WP$', 'WP$', '', '', 'D'],
|
82
|
+
'Interjection', ['', '', '', '', '', 'I'],
|
83
|
+
'Localizer', ['', '', '', '', 'LC'],
|
84
|
+
|
85
|
+
'Measure word', ['', '', '', '', 'M'],
|
86
|
+
|
87
|
+
'Noun, common', ['NN0', 'NN', 'NN', 'N', 'NN', 'NN'],
|
88
|
+
'Noun, singular', ['NN1', 'NN', 'NN', 'NN', 'NN', 'N'],
|
89
|
+
'Noun, plural', ['NN2', 'NNS', 'NNS', 'NN', 'NN', 'N'],
|
90
|
+
'Noun, proper, singular', ['NP0', 'NP', 'NNP', 'NE', 'NR', 'N'],
|
91
|
+
'Noun, proper, plural', ['NP0', 'NPS', 'NNPS', 'NE', 'NR', 'N'],
|
92
|
+
'Noun, adverbial', ['NN0', 'NR', 'NN', 'NE', '', 'N'],
|
93
|
+
'Noun, adverbial, plural', ['NN2', 'NRS', 'NNS', '', 'N'],
|
94
|
+
'Noun, temporal', ['', '', '', '', 'NT', 'N'],
|
95
|
+
'Noun, verbal', ['', '', '', '', 'NN', 'N'],
|
96
|
+
|
97
|
+
'Pronoun, nominal (indefinite)', ['PNI', 'PN', 'PRP', '', 'PN', 'CL'],
|
98
|
+
'Pronoun, personal, subject', ['PNP', 'PPSS', 'PRP', 'PPER'],
|
99
|
+
'Pronoun, personal, subject, 3SG', ['PNP', 'PPS', 'PRP', 'PPER'],
|
100
|
+
'Pronoun, personal, object', ['PNP', 'PPO', 'PRP', 'PPER'],
|
101
|
+
'Pronoun, reflexive', ['PNX', 'PPL', 'PRP', 'PRF'],
|
102
|
+
'Pronoun, reflexive, plural', ['PNX', 'PPLS', 'PRP', 'PRF'],
|
103
|
+
'Pronoun, question, subject', ['PNQ', 'WPS', 'WP', 'PWAV'],
|
104
|
+
'Pronoun, question, subject', ['PNQ', 'WPS', 'WPS', 'PWAV'], # FIXME
|
105
|
+
'Pronoun, question, object', ['PNQ', 'WPO', 'WP', 'PWAV', 'PWAT'],
|
106
|
+
'Pronoun, existential there', ['EX0', 'EX', 'EX'],
|
107
|
+
'Pronoun, attributive demonstrative', ['', '', '', 'PDAT'],
|
108
|
+
'Prounoun, attributive indefinite without determiner', ['', '', '', 'PIAT'],
|
109
|
+
'Pronoun, attributive possessive', ['', '', '', 'PPOSAT', ''],
|
110
|
+
'Pronoun, substituting demonstrative', ['', '', '', 'PDS'],
|
111
|
+
'Pronoun, substituting possessive', ['', '', '', 'PPOSS', ''],
|
112
|
+
'Prounoun, substituting indefinite', ['', '', '', 'PIS'],
|
113
|
+
'Pronoun, attributive relative', ['', '', '', 'PRELAT', ''],
|
114
|
+
'Pronoun, substituting relative', ['', '', '', 'PRELS', ''],
|
115
|
+
'Pronoun, attributive interrogative', ['', '', '', 'PWAT'],
|
116
|
+
'Pronoun, adverbial interrogative', ['', '', '', 'PWAV'],
|
117
|
+
|
118
|
+
'Pronoun, substituting interrogative', ['', '', '', 'PWS'],
|
119
|
+
'Verb, main, finite', ['', '', '', 'VVFIN', '', 'V'],
|
120
|
+
'Verb, main, infinitive', ['', '', '', 'VVINF', '', 'V'],
|
121
|
+
'Verb, main, imperative', ['', '', '', 'VVIMP', '', 'V'],
|
122
|
+
'Verb, base present form (not infinitive)', ['VVB', 'VB', 'VBP', '', '', 'V'],
|
123
|
+
'Verb, infinitive', ['VVI', 'VB', 'VB', 'V', '', 'V'],
|
124
|
+
'Verb, past tense', ['VVD', 'VBD', 'VBD', '', '', 'V'],
|
125
|
+
'Verb, present participle', ['VVG', 'VBG', 'VBG', 'VAPP', '', 'V'],
|
126
|
+
'Verb, past/passive participle', ['VVN', 'VBN', 'VBN', 'VVPP', '', 'V'],
|
127
|
+
'Verb, present, 3SG, -s form', ['VVZ', 'VBZ', 'VBZ', '', '', 'V'],
|
128
|
+
'Verb, auxiliary', ['', '', '', 'VAFIN', '', 'V'],
|
129
|
+
'Verb, imperative', ['', '', '', 'VAIMP', '', 'V'],
|
130
|
+
'Verb, imperative infinitive', ['', '', '', 'VAINF', '', 'V'],
|
131
|
+
'Verb, auxiliary do, base', ['VDB', 'DO', 'VBP', '', '', 'V'],
|
132
|
+
'Verb, auxiliary do, infinitive', ['VDB', 'DO', 'VB', '', '', 'V'],
|
133
|
+
'Verb, auxiliary do, past', ['VDD', 'DOD', 'VBD', '', '', 'V'],
|
134
|
+
'Verb, auxiliary do, present participle', ['VDG', 'VBG', 'VBG', '', '', 'V'],
|
135
|
+
'Verb, auxiliary do, past participle', ['VDN', 'VBN', 'VBN', '', '', 'V'],
|
136
|
+
'Verb, auxiliary do, present 3SG', ['VDZ', 'DOZ', 'VBZ', '', '', 'V'],
|
137
|
+
'Verb, auxiliary have, base', ['VHB', 'HV', 'VBP', 'VA', '', 'V'],
|
138
|
+
'Verb, auxiliary have, infinitive', ['VHI', 'HV', 'VB', 'VAINF', '', 'V'],
|
139
|
+
'Verb, auxiliary have, past', ['VHD', 'HVD', 'VBD', 'VA', '', 'V'],
|
140
|
+
'Verb, auxiliary have, present participle', ['VHG', 'HVG', 'VBG', 'VA', '', 'V'],
|
141
|
+
'Verb, auxiliary have, past participle', ['VHN', 'HVN', 'VBN', 'VAPP', '', 'V'],
|
142
|
+
'Verb, auxiliary have, present 3SG', ['VHZ', 'HVZ', 'VBZ', 'VA', '', 'V'],
|
143
|
+
'Verb, auxiliary be, infinitive', ['VBI', 'BE', 'VB', '', '', 'V'],
|
144
|
+
'Verb, auxiliary be, past', ['VBD', 'BED', 'VBD', '', '', 'V'],
|
145
|
+
'Verb, auxiliary be, past, 3SG', ['VBD', 'BEDZ', 'VBD', '', '', 'V'],
|
146
|
+
'Verb, auxiliary be, present participle', ['VBG', 'BEG', 'VBG', '', '', 'V'],
|
147
|
+
'Verb, auxiliary be, past participle', ['VBN', 'BEN', 'VBN', '', '', 'V'],
|
148
|
+
'Verb, auxiliary be, present, 3SG', ['VBZ', 'BEZ', 'VBZ', '', '', 'V'],
|
149
|
+
'Verb, auxiliary be, present, 1SG', ['VBB', 'BEM', 'VBP', '', '', 'V'],
|
150
|
+
'Verb, auxiliary be, present', ['VBB', 'BER', 'VBP', '', '', 'V'],
|
151
|
+
'Verb, modal', ['VM0', 'MD', 'MD', 'VMFIN', 'VV', 'V'],
|
152
|
+
'Verb, modal', ['VM0', 'MD', 'MD', 'VMINF', 'VV', 'V'],
|
153
|
+
'Verb, modal, finite', ['', '', '', '', 'VMFIN', 'V'],
|
154
|
+
'Verb, modal, infinite', ['', '', '', '', 'VMINF', 'V'],
|
155
|
+
'Verb, modal, past participle', ['', '', '', '', 'VMPP', 'V'],
|
156
|
+
|
157
|
+
'Particle', ['', '', '', '', '', 'PRT'],
|
158
|
+
'Particle, with adverb', ['', '', '', 'PTKA', '', 'PRT'],
|
159
|
+
'Particle, answer', ['', '', '', 'PTKANT', '', 'PRT'],
|
160
|
+
'Particle, negation', ['', '', '', 'PTKNEG', '', 'PRT'],
|
161
|
+
'Particle, separated verb', ['', '', '', 'PTKVZ', '', 'PRT'],
|
162
|
+
'Particle, to as infinitive marker', ['TO0', 'TO', 'TO', 'PTKZU', '', 'PRT'],
|
163
|
+
|
164
|
+
'Preposition, comparative', ['', '', '', 'KOKOM', '', 'P'],
|
165
|
+
'Preposition, to', ['PRP', 'IN', 'TO', '', '', 'P'],
|
166
|
+
'Preposition', ['PRP', 'IN', 'IN', 'APPR', 'P', 'P'],
|
167
|
+
'Preposition, with aritcle', ['', '', '', 'APPART', '', 'P'],
|
168
|
+
'Preposition, of', ['PRF', 'IN', 'IN', '', '', 'P'],
|
169
|
+
|
170
|
+
'Possessive', ['POS', '$', 'POS'],
|
171
|
+
|
172
|
+
'Postposition', ['', '', '', 'APPO'],
|
173
|
+
|
174
|
+
'Circumposition, right', ['', '', '', 'APZR', ''],
|
175
|
+
|
176
|
+
'Interjection, onomatopoeia or other isolate', ['ITJ', 'UH', 'UH', 'ITJ', 'IJ'],
|
177
|
+
|
178
|
+
'Onomatopoeia', ['', '', '', '', 'ON'],
|
179
|
+
|
180
|
+
'Punctuation', ['', '', '', '', 'PU', 'PN'],
|
181
|
+
'Punctuation, sentence ender', ['PUN', '.', '.', '', '', 'PN'],
|
182
|
+
|
183
|
+
'Punctuation, semicolon', ['PUN', '.', '.', '', '', 'PN'],
|
184
|
+
'Puncutation, colon or ellipsis', ['PUN', ':', ':'],
|
185
|
+
'Punctuationm, comma', ['PUN', ',', ',', '$,'],
|
186
|
+
'Punctuation, dash', ['PUN', '-', '-'],
|
187
|
+
'Punctuation, dollar sign', ['PUN', '', '$'],
|
188
|
+
'Punctuation, left bracket', ['PUL', '(', '(', '$('],
|
189
|
+
'Punctuation, right bracket', ['PUR', ')', ')'],
|
190
|
+
'Punctuation, quotation mark, left', ['PUQ', '', '``'],
|
191
|
+
'Punctuation, quotation mark, right', ['PUQ', '', '"'],
|
192
|
+
|
193
|
+
'Punctuation, left bracket', ['PUL', '(', 'PPL'],
|
194
|
+
'Punctuation, right bracket', ['PUR', ')', 'PPR'],
|
195
|
+
'Punctuation, left square bracket', ['PUL', '(', 'LSB'],
|
196
|
+
'Punctuation, right square bracket', ['PUR', ')', 'RSB'],
|
197
|
+
'Punctuation, left curly bracket', ['PUL', '(', 'LCB'],
|
198
|
+
'Punctuation, right curly bracket', ['PUR', ')', 'RCB'],
|
199
|
+
|
200
|
+
'Unknown, foreign words (not in lexicon)', ['UNZ', '(FW-)', 'FW', '', 'FW'],
|
201
|
+
|
202
|
+
'Symbol', ['', '', 'SYM', 'XY'],
|
203
|
+
'Symbol, alphabetical', ['ZZ0', '', ''],
|
204
|
+
'Symbol, list item', ['', '', 'LS'],
|
205
|
+
|
206
|
+
# Not sure about these tags from the Chinese PTB.
|
207
|
+
'Aspect marker', ['', '', '', '', 'AS'], # ?
|
208
|
+
'Ba-construction', ['', '', '', '', 'BA'], # ?
|
209
|
+
'In relative', ['', '', '', '', 'DEC'], # ?
|
210
|
+
'Associative', ['', '', '', '', 'DER'], # ?
|
211
|
+
'In V-de or V-de-R construct', ['', '', '', '', 'DER'], # ?
|
212
|
+
'For words ? ', ['', '', '', '', 'ETC'], # ?
|
213
|
+
'In long bei-construct', ['', '', '', '', 'LB'], # ?
|
214
|
+
'In short bei-construct', ['', '', '', '', 'SB'], # ?
|
215
|
+
'Sentence-nal particle', ['', '', '', '', 'SB'], # ?
|
216
|
+
'Particle, other', ['', '', '', '', 'MSP'], # ?
|
217
|
+
'Before VP', ['', '', '', '', 'DEV'], # ?
|
218
|
+
'Verb, ? as main verb', ['', '', '', '', 'VE'], # ?
|
219
|
+
'Verb, ????', ['', '', '', '', 'VC'] # ?
|
220
|
+
]},
|
221
|
+
enju: {
|
222
|
+
cat_to_category: {
|
223
|
+
'ADJ' => 'adjective',
|
224
|
+
'ADV' => 'adverb',
|
225
|
+
'CONJ' => 'conjunction',
|
226
|
+
'COOD' => 'conjunction',
|
227
|
+
'C' => 'complementizer',
|
228
|
+
'D' => 'determiner',
|
229
|
+
'N' => 'noun',
|
230
|
+
'P' => 'preposition',
|
231
|
+
'PN' => 'punctuation',
|
232
|
+
'SC' => 'conjunction',
|
233
|
+
'V' => 'verb',
|
234
|
+
'PRT' => 'particle'
|
235
|
+
},
|
236
|
+
cat_to_description: [
|
237
|
+
['ADJ', 'Adjective'],
|
238
|
+
['ADV', 'Adverb'],
|
239
|
+
['CONJ', 'Coordination conjunction'],
|
240
|
+
['C', 'Complementizer'],
|
241
|
+
['D', 'Determiner'],
|
242
|
+
['N', 'Noun'],
|
243
|
+
['P', 'Preposition'],
|
244
|
+
['SC', 'Subordination conjunction'],
|
245
|
+
['V', 'Verb'],
|
246
|
+
['COOD', 'Part of coordination'],
|
247
|
+
['PN', 'Punctuation'],
|
248
|
+
['PRT', 'Particle'],
|
249
|
+
['S', 'Sentence']
|
250
|
+
],
|
251
|
+
xcat_to_description: [
|
252
|
+
['COOD', 'Coordinated phrase/clause'],
|
253
|
+
['IMP', 'Imperative sentence'],
|
254
|
+
['INV', 'Subject-verb inversion'],
|
255
|
+
['Q', 'Interrogative sentence with subject-verb inversion'],
|
256
|
+
['REL', 'A relativizer included'],
|
257
|
+
['FREL', 'A free relative included'],
|
258
|
+
['TRACE', 'A trace included'],
|
259
|
+
['WH', 'A wh-question word included']
|
260
|
+
],
|
261
|
+
xcat_to_ptb: [
|
262
|
+
['ADJP', '', 'ADJP'],
|
263
|
+
['ADJP', 'REL', 'WHADJP'],
|
264
|
+
['ADJP', 'FREL', 'WHADJP'],
|
265
|
+
['ADJP', 'WH', 'WHADJP'],
|
266
|
+
['ADVP', '', 'ADVP'],
|
267
|
+
['ADVP', 'REL', 'WHADVP'],
|
268
|
+
['ADVP', 'FREL', 'WHADVP'],
|
269
|
+
['ADVP', 'WH', 'WHADVP'],
|
270
|
+
['CONJP', '', 'CONJP'],
|
271
|
+
['CP', '', 'SBAR'],
|
272
|
+
['DP', '', 'NP'],
|
273
|
+
['NP', '', 'NP'],
|
274
|
+
['NX', 'NX', 'NAC'],
|
275
|
+
['NP' 'REL' 'WHNP'],
|
276
|
+
['NP' 'FREL' 'WHNP'],
|
277
|
+
['NP' 'WH' 'WHNP'],
|
278
|
+
['PP', '', 'PP'],
|
279
|
+
['PP', 'REL', 'WHPP'],
|
280
|
+
['PP', 'WH', 'WHPP'],
|
281
|
+
['PRT', '', 'PRT'],
|
282
|
+
['S', '', 'S'],
|
283
|
+
['S', 'INV', 'SINV'],
|
284
|
+
['S', 'Q', 'SQ'],
|
285
|
+
['S', 'REL', 'SBAR'],
|
286
|
+
['S', 'FREL', 'SBAR'],
|
287
|
+
['S', 'WH', 'SBARQ'],
|
288
|
+
['SCP', '', 'SBAR'],
|
289
|
+
['VP', '', 'VP'],
|
290
|
+
['VP', '', 'VP'],
|
291
|
+
['', '', 'UK']
|
292
|
+
]},
|
293
|
+
paris7: {
|
294
|
+
tag_to_category: {
|
295
|
+
'C' => :complementizer,
|
296
|
+
'PN' => :punctuation,
|
297
|
+
'SC' => :conjunction
|
298
|
+
}
|
299
|
+
# Paris7 Treebank functional tags
|
300
|
+
=begin
|
301
|
+
SUJ (subject)
|
302
|
+
OBJ (direct object)
|
303
|
+
ATS (predicative complement of a subject)
|
304
|
+
ATO (predicative complement of a direct object)
|
305
|
+
MOD (modifier or adjunct)
|
306
|
+
A-OBJ (indirect complement introduced by à)
|
307
|
+
DE-OBJ (indirect complement introduced by de)
|
308
|
+
P-OBJ (indirect complement introduced by another preposition)
|
309
|
+
=end
|
310
|
+
},
|
311
|
+
ptb: {
|
312
|
+
escape_characters: {
|
313
|
+
'(' => '-LRB-',
|
314
|
+
')' => '-RRB-',
|
315
|
+
'[' => '-LSB-',
|
316
|
+
']' => '-RSB-',
|
317
|
+
'{' => '-LCB-',
|
318
|
+
'}' => '-RCB-'
|
319
|
+
},
|
320
|
+
phrase_tag_to_description: [
|
321
|
+
['S', 'Paris7 declarative clause'],
|
322
|
+
['SBAR', 'Clause introduced by a (possibly empty) subordinating conjunction'],
|
323
|
+
['SBARQ', 'Direct question introduced by a wh-word or a wh-phrase'],
|
324
|
+
['SINV', 'Inverted declarative sentence'],
|
325
|
+
['SQ', 'Inverted yes/no question']
|
326
|
+
]
|
327
|
+
}
|
328
|
+
}
|
@@ -6,7 +6,7 @@
|
|
6
6
|
},
|
7
7
|
time: {
|
8
8
|
type: :annotator,
|
9
|
-
targets: [:
|
9
|
+
targets: [:group]
|
10
10
|
},
|
11
11
|
topics: {
|
12
12
|
type: :annotator,
|
@@ -22,18 +22,10 @@
|
|
22
22
|
},
|
23
23
|
name_tag: {
|
24
24
|
type: :annotator,
|
25
|
-
targets: [:
|
26
|
-
},
|
27
|
-
coreferences: {
|
28
|
-
type: :annotator,
|
29
|
-
targets: [:zone]
|
25
|
+
targets: [:group]
|
30
26
|
},
|
31
27
|
tf_idf: {
|
32
28
|
type: :annotator,
|
33
29
|
targets: [:word]
|
34
|
-
},
|
35
|
-
summary: {
|
36
|
-
type: :annotator,
|
37
|
-
targets: [:document]
|
38
30
|
}
|
39
31
|
}
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,11 +1,12 @@
|
|
1
1
|
{
|
2
2
|
taggers: {
|
3
3
|
type: :annotator,
|
4
|
-
targets: [:
|
4
|
+
targets: [:group, :token],
|
5
|
+
recursive: true
|
5
6
|
},
|
6
7
|
categorizers: {
|
7
8
|
type: :annotator,
|
8
|
-
targets: [:
|
9
|
+
targets: [:group, :token],
|
9
10
|
recursive: true
|
10
11
|
},
|
11
12
|
sensers: {
|
@@ -14,5 +15,5 @@
|
|
14
15
|
preset_option: :nym,
|
15
16
|
presets: [:synonyms, :antonyms,
|
16
17
|
:hyponyms, :hypernyms],
|
17
|
-
}
|
18
|
+
}
|
18
19
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
chunkers: {
|
3
3
|
type: :transformer,
|
4
|
-
targets: [:document],
|
4
|
+
targets: [:document, :section],
|
5
5
|
default: :autoselect
|
6
6
|
},
|
7
7
|
segmenters: {
|
@@ -10,10 +10,10 @@
|
|
10
10
|
},
|
11
11
|
tokenizers: {
|
12
12
|
type: :transformer,
|
13
|
-
targets: [:
|
13
|
+
targets: [:group]
|
14
14
|
},
|
15
15
|
parsers: {
|
16
16
|
type: :transformer,
|
17
|
-
targets: [:
|
17
|
+
targets: [:group]
|
18
18
|
}
|
19
19
|
}
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Mixin that is extended by Treat::Config
|
2
|
+
# in order to provide a single point of
|
3
|
+
# access method to trigger the import.
|
4
|
+
module Treat::Config::Importable
|
5
|
+
|
6
|
+
# Import relies on each configuration.
|
7
|
+
require_relative 'configurable'
|
8
|
+
|
9
|
+
# Store all the configuration in self.config
|
10
|
+
def self.extended(base)
|
11
|
+
class << base; attr_accessor :config; end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Main function; loads all configuration options.
|
15
|
+
def import!
|
16
|
+
config, c = {}, Treat::Config::Configurable
|
17
|
+
definition = :define_singleton_method
|
18
|
+
Treat::Config.constants.each do |const|
|
19
|
+
next if const.to_s.downcase.is_mixin?
|
20
|
+
klass = Treat::Config.const_get(const)
|
21
|
+
klass.class_eval { extend c }.configure!
|
22
|
+
name = const.to_s.downcase.intern
|
23
|
+
config[name] = klass.config
|
24
|
+
Treat.send(definition, name) do
|
25
|
+
Treat::Config.config[name]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
self.config = config.to_struct
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generates the following path config options:
|
2
|
+
# Treat.paths.tmp, Treat.paths.bin, Treat.paths.lib,
|
3
|
+
# Treat.paths.models, Treat.paths.files, Treat.paths.spec.
|
4
|
+
class Treat::Config::Paths
|
5
|
+
|
6
|
+
# Get the path configuration based on the
|
7
|
+
# directory structure loaded into Paths.
|
8
|
+
# Note that this doesn't call super, as
|
9
|
+
# there is no external config files to load.
|
10
|
+
def self.configure!
|
11
|
+
root = File.dirname(File.expand_path( # FIXME
|
12
|
+
__FILE__)).split('/')[0..-4].join('/') + '/'
|
13
|
+
self.config = Hash[
|
14
|
+
# Get a list of directories in treat/
|
15
|
+
Dir.glob(root + '*').select do |path|
|
16
|
+
FileTest.directory?(path)
|
17
|
+
# Map to pairs of [:name, path]
|
18
|
+
end.map do |path|
|
19
|
+
[File.basename(path).intern, path + '/']
|
20
|
+
end]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Handles all configuration related
|
2
|
+
# to understanding of part of speech
|
3
|
+
# and phrasal tags.
|
4
|
+
class Treat::Config::Tags
|
5
|
+
|
6
|
+
# Generate a map of word and phrase tags
|
7
|
+
# to their syntactic category, keyed by
|
8
|
+
# tag set.
|
9
|
+
def self.configure!
|
10
|
+
super
|
11
|
+
config = self.config[:aligned].dup
|
12
|
+
word_tags, phrase_tags, tag_sets =
|
13
|
+
config[:word_tags], config[:phrase_tags]
|
14
|
+
tag_sets = config[:tag_sets]
|
15
|
+
config[:word_tags_to_category] =
|
16
|
+
align_tags(word_tags, tag_sets)
|
17
|
+
config[:phrase_tags_to_category] =
|
18
|
+
align_tags(phrase_tags, tag_sets)
|
19
|
+
self.config[:aligned] = config
|
20
|
+
end
|
21
|
+
|
22
|
+
# Helper methods for tag set config.
|
23
|
+
# Align tag tags in the tag set
|
24
|
+
def self.align_tags(tags, tag_sets)
|
25
|
+
wttc = {}
|
26
|
+
tags.each_slice(2) do |desc, tags|
|
27
|
+
category = desc.gsub(',', ' ,').
|
28
|
+
split(' ')[0].downcase
|
29
|
+
tag_sets.each_with_index do |tag_set, i|
|
30
|
+
next unless tags[i]
|
31
|
+
wttc[tags[i]] ||= {}
|
32
|
+
wttc[tags[i]][tag_set] = category
|
33
|
+
end
|
34
|
+
end; return wttc
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Treat::Core::DSL
|
2
|
+
|
3
|
+
# Message for deprecation of old DSL syntax.
|
4
|
+
DeprecationMessage = "The DSL that used " +
|
5
|
+
"capitalized entity names is now deprecated. " +
|
6
|
+
"Use `include Treat::Core::DSL` along with " +
|
7
|
+
"lowercase names from now on."
|
8
|
+
|
9
|
+
# Map all classes in Treat::Entities to
|
10
|
+
# a global builder function (entity, word,
|
11
|
+
# phrase, punctuation, symbol, list, etc.)
|
12
|
+
def self.included(base)
|
13
|
+
self.sweeten_entities(base)
|
14
|
+
self.sweeten_learning(base)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Map all classes in Treat::Entities to
|
18
|
+
# a global builder function (word, etc.)
|
19
|
+
def self.sweeten_entities(base, on = true)
|
20
|
+
Treat.core.entities.list.each do |type|
|
21
|
+
kname = type.cc.intern
|
22
|
+
mname = type.intern
|
23
|
+
klass = Treat::Entities.const_get(kname)
|
24
|
+
base.class_eval do
|
25
|
+
define_method(mname.capitalize) do |*args|
|
26
|
+
raise DeprecationMessage
|
27
|
+
end
|
28
|
+
old_mm = instance_method(:method_missing)
|
29
|
+
define_method(:method_missing) do |sym,*args,&block|
|
30
|
+
return klass.build(*args) if sym == mname
|
31
|
+
old_mm.bind(self).call(sym,*args,&block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Map all classes in the Learning module
|
38
|
+
# to a global builder function. Defines:
|
39
|
+
# dataset, export, feature, tag, problem
|
40
|
+
# question.
|
41
|
+
def self.sweeten_learning(base, on = true)
|
42
|
+
Treat::Learning.constants.each do |kname|
|
43
|
+
mname = kname.downcase
|
44
|
+
klass = Treat::Learning.const_get(kname)
|
45
|
+
base.class_eval do
|
46
|
+
old_mm = instance_method(:method_missing)
|
47
|
+
define_method(:method_missing) do |sym,*args,&block|
|
48
|
+
return klass.new(*args) if sym == mname
|
49
|
+
old_mm.bind(self).call(sym,*args,&block)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -1,13 +1,7 @@
|
|
1
1
|
# A dependency manager for Treat language plugins.
|
2
|
-
#
|
3
|
-
module Treat::Installer
|
4
|
-
|
5
|
-
# Require the Rubygem dependency installer.
|
6
|
-
silence_warnings do
|
7
|
-
require 'rubygems/dependency_installer'
|
8
|
-
end
|
2
|
+
# Usage: Treat::Installer.install('language')
|
3
|
+
module Treat::Core::Installer
|
9
4
|
|
10
|
-
require 'treat/version'
|
11
5
|
require 'schiphol'
|
12
6
|
|
13
7
|
# Address of the server with the files.
|
@@ -31,6 +25,11 @@ module Treat::Installer
|
|
31
25
|
# dependencies for a specific language.
|
32
26
|
def self.install(language = 'english')
|
33
27
|
|
28
|
+
# Require the Rubygem dependency installer.
|
29
|
+
silence_warnings do
|
30
|
+
require 'rubygems/dependency_installer'
|
31
|
+
end
|
32
|
+
|
34
33
|
@@installer = Gem::DependencyInstaller.new
|
35
34
|
|
36
35
|
if language == 'travis'
|
@@ -182,10 +181,9 @@ module Treat::Installer
|
|
182
181
|
begin
|
183
182
|
puts "Installing #{dependency}...\n"
|
184
183
|
@@installer.install(dependency)
|
185
|
-
rescue
|
186
|
-
|
187
|
-
|
188
|
-
"(#{error.message})."
|
184
|
+
rescue Gem::InstallError => error
|
185
|
+
puts "Warning: couldn't install " +
|
186
|
+
"gem '#{dependency}' (#{error.message})."
|
189
187
|
end
|
190
188
|
|
191
189
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Treat::Core::Server
|
2
|
+
|
3
|
+
# Refer to http://rack.rubyforge.org/doc/classes/Rack/Server.html
|
4
|
+
# for possible options to configure.
|
5
|
+
def initialize(handler = 'thin', options = {})
|
6
|
+
require 'json'; require 'rack'
|
7
|
+
@handler, @options = handler.capitalize, options
|
8
|
+
end
|
9
|
+
|
10
|
+
def start
|
11
|
+
handler = Rack::Handler.const_get(@handler)
|
12
|
+
handler.run(self, @options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
headers = { 'content-type' => 'application/json' }
|
17
|
+
rack_input = env["rack.input"].read
|
18
|
+
if rack_input.strip == ''
|
19
|
+
return [500, headers, {
|
20
|
+
'error' => 'Empty JSON request.'
|
21
|
+
}]
|
22
|
+
end
|
23
|
+
rack_json = JSON.parse(rack_input)
|
24
|
+
unless rack_json['type'] &&
|
25
|
+
rack_json['value'] && rack_json['do']
|
26
|
+
return [500, headers, {
|
27
|
+
'error' => 'Must specify "type", "value" and "do".'
|
28
|
+
}]
|
29
|
+
end
|
30
|
+
if rack_json['conf']
|
31
|
+
# Set the configuration.
|
32
|
+
end
|
33
|
+
method = rack_json['type'].capitalize.intern
|
34
|
+
resp = send(method, rack_json[value]).do(rack_json['do'])
|
35
|
+
|
36
|
+
response = [rack_input.to_json]
|
37
|
+
[200, headers, response]
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|