grammar_cop 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.DS_Store +0 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +8 -0
- data/data/.DS_Store +0 -0
- data/data/Makefile +511 -0
- data/data/Makefile.am +4 -0
- data/data/Makefile.in +511 -0
- data/data/de/.DS_Store +0 -0
- data/data/de/4.0.affix +7 -0
- data/data/de/4.0.dict +474 -0
- data/data/de/Makefile +387 -0
- data/data/de/Makefile.am +9 -0
- data/data/de/Makefile.in +387 -0
- data/data/en/.DS_Store +0 -0
- data/data/en/4.0.affix +26 -0
- data/data/en/4.0.batch +1002 -0
- data/data/en/4.0.biolg.batch +411 -0
- data/data/en/4.0.constituent-knowledge +127 -0
- data/data/en/4.0.dict +8759 -0
- data/data/en/4.0.dict.m4 +6928 -0
- data/data/en/4.0.enwiki.batch +14 -0
- data/data/en/4.0.fixes.batch +2776 -0
- data/data/en/4.0.knowledge +306 -0
- data/data/en/4.0.regex +225 -0
- data/data/en/4.0.voa.batch +114 -0
- data/data/en/Makefile +554 -0
- data/data/en/Makefile.am +19 -0
- data/data/en/Makefile.in +554 -0
- data/data/en/README +173 -0
- data/data/en/tiny.dict +157 -0
- data/data/en/words/.DS_Store +0 -0
- data/data/en/words/Makefile +456 -0
- data/data/en/words/Makefile.am +78 -0
- data/data/en/words/Makefile.in +456 -0
- data/data/en/words/currency +205 -0
- data/data/en/words/currency.p +28 -0
- data/data/en/words/entities.given-bisex.sing +39 -0
- data/data/en/words/entities.given-female.sing +4141 -0
- data/data/en/words/entities.given-male.sing +1633 -0
- data/data/en/words/entities.locations.sing +68 -0
- data/data/en/words/entities.national.sing +253 -0
- data/data/en/words/entities.organizations.sing +7 -0
- data/data/en/words/entities.us-states.sing +11 -0
- data/data/en/words/units.1 +45 -0
- data/data/en/words/units.1.dot +4 -0
- data/data/en/words/units.3 +2 -0
- data/data/en/words/units.4 +5 -0
- data/data/en/words/units.4.dot +1 -0
- data/data/en/words/words-medical.adv.1 +1191 -0
- data/data/en/words/words-medical.prep.1 +67 -0
- data/data/en/words/words-medical.v.4.1 +2835 -0
- data/data/en/words/words-medical.v.4.2 +2848 -0
- data/data/en/words/words-medical.v.4.3 +3011 -0
- data/data/en/words/words-medical.v.4.4 +3036 -0
- data/data/en/words/words-medical.v.4.5 +3050 -0
- data/data/en/words/words.adj.1 +6794 -0
- data/data/en/words/words.adj.2 +638 -0
- data/data/en/words/words.adj.3 +667 -0
- data/data/en/words/words.adv.1 +1573 -0
- data/data/en/words/words.adv.2 +67 -0
- data/data/en/words/words.adv.3 +157 -0
- data/data/en/words/words.adv.4 +80 -0
- data/data/en/words/words.n.1 +11464 -0
- data/data/en/words/words.n.1.wiki +264 -0
- data/data/en/words/words.n.2.s +2017 -0
- data/data/en/words/words.n.2.s.biolg +1 -0
- data/data/en/words/words.n.2.s.wiki +298 -0
- data/data/en/words/words.n.2.x +65 -0
- data/data/en/words/words.n.2.x.wiki +10 -0
- data/data/en/words/words.n.3 +5717 -0
- data/data/en/words/words.n.t +23 -0
- data/data/en/words/words.v.1.1 +1038 -0
- data/data/en/words/words.v.1.2 +1043 -0
- data/data/en/words/words.v.1.3 +1052 -0
- data/data/en/words/words.v.1.4 +1023 -0
- data/data/en/words/words.v.1.p +17 -0
- data/data/en/words/words.v.10.1 +14 -0
- data/data/en/words/words.v.10.2 +15 -0
- data/data/en/words/words.v.10.3 +88 -0
- data/data/en/words/words.v.10.4 +17 -0
- data/data/en/words/words.v.2.1 +1253 -0
- data/data/en/words/words.v.2.2 +1304 -0
- data/data/en/words/words.v.2.3 +1280 -0
- data/data/en/words/words.v.2.4 +1285 -0
- data/data/en/words/words.v.2.5 +1287 -0
- data/data/en/words/words.v.4.1 +2472 -0
- data/data/en/words/words.v.4.2 +2487 -0
- data/data/en/words/words.v.4.3 +2441 -0
- data/data/en/words/words.v.4.4 +2478 -0
- data/data/en/words/words.v.4.5 +2483 -0
- data/data/en/words/words.v.5.1 +98 -0
- data/data/en/words/words.v.5.2 +98 -0
- data/data/en/words/words.v.5.3 +103 -0
- data/data/en/words/words.v.5.4 +102 -0
- data/data/en/words/words.v.6.1 +388 -0
- data/data/en/words/words.v.6.2 +401 -0
- data/data/en/words/words.v.6.3 +397 -0
- data/data/en/words/words.v.6.4 +405 -0
- data/data/en/words/words.v.6.5 +401 -0
- data/data/en/words/words.v.8.1 +117 -0
- data/data/en/words/words.v.8.2 +118 -0
- data/data/en/words/words.v.8.3 +118 -0
- data/data/en/words/words.v.8.4 +119 -0
- data/data/en/words/words.v.8.5 +119 -0
- data/data/en/words/words.y +104 -0
- data/data/lt/.DS_Store +0 -0
- data/data/lt/4.0.affix +6 -0
- data/data/lt/4.0.constituent-knowledge +24 -0
- data/data/lt/4.0.dict +135 -0
- data/data/lt/4.0.knowledge +38 -0
- data/data/lt/Makefile +389 -0
- data/data/lt/Makefile.am +11 -0
- data/data/lt/Makefile.in +389 -0
- data/ext/.DS_Store +0 -0
- data/ext/link_grammar/.DS_Store +0 -0
- data/ext/link_grammar/extconf.rb +2 -0
- data/ext/link_grammar/link-grammar/.DS_Store +0 -0
- data/ext/link_grammar/link-grammar/.deps/analyze-linkage.Plo +198 -0
- data/ext/link_grammar/link-grammar/.deps/and.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/api.Plo +244 -0
- data/ext/link_grammar/link-grammar/.deps/build-disjuncts.Plo +212 -0
- data/ext/link_grammar/link-grammar/.deps/command-line.Plo +201 -0
- data/ext/link_grammar/link-grammar/.deps/constituents.Plo +201 -0
- data/ext/link_grammar/link-grammar/.deps/count.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/disjunct-utils.Plo +126 -0
- data/ext/link_grammar/link-grammar/.deps/disjuncts.Plo +123 -0
- data/ext/link_grammar/link-grammar/.deps/error.Plo +121 -0
- data/ext/link_grammar/link-grammar/.deps/expand.Plo +133 -0
- data/ext/link_grammar/link-grammar/.deps/extract-links.Plo +198 -0
- data/ext/link_grammar/link-grammar/.deps/fast-match.Plo +200 -0
- data/ext/link_grammar/link-grammar/.deps/idiom.Plo +200 -0
- data/ext/link_grammar/link-grammar/.deps/jni-client.Plo +217 -0
- data/ext/link_grammar/link-grammar/.deps/link-parser.Po +1 -0
- data/ext/link_grammar/link-grammar/.deps/massage.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/post-process.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/pp_knowledge.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/pp_lexer.Plo +201 -0
- data/ext/link_grammar/link-grammar/.deps/pp_linkset.Plo +200 -0
- data/ext/link_grammar/link-grammar/.deps/prefix.Plo +102 -0
- data/ext/link_grammar/link-grammar/.deps/preparation.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/print-util.Plo +200 -0
- data/ext/link_grammar/link-grammar/.deps/print.Plo +201 -0
- data/ext/link_grammar/link-grammar/.deps/prune.Plo +202 -0
- data/ext/link_grammar/link-grammar/.deps/read-dict.Plo +223 -0
- data/ext/link_grammar/link-grammar/.deps/read-regex.Plo +123 -0
- data/ext/link_grammar/link-grammar/.deps/regex-morph.Plo +131 -0
- data/ext/link_grammar/link-grammar/.deps/resources.Plo +203 -0
- data/ext/link_grammar/link-grammar/.deps/spellcheck-aspell.Plo +1 -0
- data/ext/link_grammar/link-grammar/.deps/spellcheck-hun.Plo +115 -0
- data/ext/link_grammar/link-grammar/.deps/string-set.Plo +198 -0
- data/ext/link_grammar/link-grammar/.deps/tokenize.Plo +160 -0
- data/ext/link_grammar/link-grammar/.deps/utilities.Plo +222 -0
- data/ext/link_grammar/link-grammar/.deps/word-file.Plo +201 -0
- data/ext/link_grammar/link-grammar/.deps/word-utils.Plo +212 -0
- data/ext/link_grammar/link-grammar/.libs/analyze-linkage.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/and.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/api.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/build-disjuncts.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/command-line.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/constituents.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/count.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/disjunct-utils.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/disjuncts.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/error.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/expand.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/extract-links.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/fast-match.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/idiom.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/jni-client.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-java-symbols.expsym +31 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-java.4.dylib +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-java.4.dylib.dSYM/Contents/Info.plist +20 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-java.4.dylib.dSYM/Contents/Resources/DWARF/liblink-grammar-java.4.dylib +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-java.a +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-java.dylib +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar-symbols.expsym +194 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.4.dylib +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.4.dylib.dSYM/Contents/Info.plist +20 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.4.dylib.dSYM/Contents/Resources/DWARF/liblink-grammar.4.dylib +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.a +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.dylib +0 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.la +41 -0
- data/ext/link_grammar/link-grammar/.libs/liblink-grammar.lai +41 -0
- data/ext/link_grammar/link-grammar/.libs/massage.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/post-process.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/pp_knowledge.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/pp_lexer.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/pp_linkset.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/prefix.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/preparation.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/print-util.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/print.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/prune.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/read-dict.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/read-regex.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/regex-morph.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/resources.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/spellcheck-aspell.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/spellcheck-hun.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/string-set.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/tokenize.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/utilities.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/word-file.o +0 -0
- data/ext/link_grammar/link-grammar/.libs/word-utils.o +0 -0
- data/ext/link_grammar/link-grammar/Makefile +900 -0
- data/ext/link_grammar/link-grammar/Makefile.am +202 -0
- data/ext/link_grammar/link-grammar/Makefile.in +900 -0
- data/ext/link_grammar/link-grammar/analyze-linkage.c +1317 -0
- data/ext/link_grammar/link-grammar/analyze-linkage.h +24 -0
- data/ext/link_grammar/link-grammar/and.c +1603 -0
- data/ext/link_grammar/link-grammar/and.h +27 -0
- data/ext/link_grammar/link-grammar/api-structures.h +362 -0
- data/ext/link_grammar/link-grammar/api-types.h +72 -0
- data/ext/link_grammar/link-grammar/api.c +1887 -0
- data/ext/link_grammar/link-grammar/api.h +96 -0
- data/ext/link_grammar/link-grammar/autoit/.DS_Store +0 -0
- data/ext/link_grammar/link-grammar/autoit/README +10 -0
- data/ext/link_grammar/link-grammar/autoit/_LGTest.au3 +22 -0
- data/ext/link_grammar/link-grammar/autoit/_LinkGrammar.au3 +545 -0
- data/ext/link_grammar/link-grammar/build-disjuncts.c +487 -0
- data/ext/link_grammar/link-grammar/build-disjuncts.h +21 -0
- data/ext/link_grammar/link-grammar/command-line.c +458 -0
- data/ext/link_grammar/link-grammar/command-line.h +15 -0
- data/ext/link_grammar/link-grammar/constituents.c +1836 -0
- data/ext/link_grammar/link-grammar/constituents.h +26 -0
- data/ext/link_grammar/link-grammar/corpus/.DS_Store +0 -0
- data/ext/link_grammar/link-grammar/corpus/.deps/cluster.Plo +1 -0
- data/ext/link_grammar/link-grammar/corpus/.deps/corpus.Plo +1 -0
- data/ext/link_grammar/link-grammar/corpus/Makefile +527 -0
- data/ext/link_grammar/link-grammar/corpus/Makefile.am +46 -0
- data/ext/link_grammar/link-grammar/corpus/Makefile.in +527 -0
- data/ext/link_grammar/link-grammar/corpus/README +17 -0
- data/ext/link_grammar/link-grammar/corpus/cluster.c +286 -0
- data/ext/link_grammar/link-grammar/corpus/cluster.h +32 -0
- data/ext/link_grammar/link-grammar/corpus/corpus.c +483 -0
- data/ext/link_grammar/link-grammar/corpus/corpus.h +46 -0
- data/ext/link_grammar/link-grammar/count.c +828 -0
- data/ext/link_grammar/link-grammar/count.h +25 -0
- data/ext/link_grammar/link-grammar/disjunct-utils.c +261 -0
- data/ext/link_grammar/link-grammar/disjunct-utils.h +27 -0
- data/ext/link_grammar/link-grammar/disjuncts.c +138 -0
- data/ext/link_grammar/link-grammar/disjuncts.h +13 -0
- data/ext/link_grammar/link-grammar/error.c +92 -0
- data/ext/link_grammar/link-grammar/error.h +35 -0
- data/ext/link_grammar/link-grammar/expand.c +67 -0
- data/ext/link_grammar/link-grammar/expand.h +13 -0
- data/ext/link_grammar/link-grammar/externs.h +22 -0
- data/ext/link_grammar/link-grammar/extract-links.c +625 -0
- data/ext/link_grammar/link-grammar/extract-links.h +16 -0
- data/ext/link_grammar/link-grammar/fast-match.c +309 -0
- data/ext/link_grammar/link-grammar/fast-match.h +17 -0
- data/ext/link_grammar/link-grammar/idiom.c +373 -0
- data/ext/link_grammar/link-grammar/idiom.h +15 -0
- data/ext/link_grammar/link-grammar/jni-client.c +779 -0
- data/ext/link_grammar/link-grammar/jni-client.h +236 -0
- data/ext/link_grammar/link-grammar/liblink-grammar-java.la +42 -0
- data/ext/link_grammar/link-grammar/liblink-grammar.la +41 -0
- data/ext/link_grammar/link-grammar/link-features.h +37 -0
- data/ext/link_grammar/link-grammar/link-features.h.in +37 -0
- data/ext/link_grammar/link-grammar/link-grammar-java.def +31 -0
- data/ext/link_grammar/link-grammar/link-grammar.def +194 -0
- data/ext/link_grammar/link-grammar/link-includes.h +465 -0
- data/ext/link_grammar/link-grammar/link-parser.c +849 -0
- data/ext/link_grammar/link-grammar/massage.c +329 -0
- data/ext/link_grammar/link-grammar/massage.h +13 -0
- data/ext/link_grammar/link-grammar/post-process.c +1113 -0
- data/ext/link_grammar/link-grammar/post-process.h +45 -0
- data/ext/link_grammar/link-grammar/pp_knowledge.c +376 -0
- data/ext/link_grammar/link-grammar/pp_knowledge.h +14 -0
- data/ext/link_grammar/link-grammar/pp_lexer.c +1920 -0
- data/ext/link_grammar/link-grammar/pp_lexer.h +19 -0
- data/ext/link_grammar/link-grammar/pp_linkset.c +158 -0
- data/ext/link_grammar/link-grammar/pp_linkset.h +20 -0
- data/ext/link_grammar/link-grammar/prefix.c +482 -0
- data/ext/link_grammar/link-grammar/prefix.h +139 -0
- data/ext/link_grammar/link-grammar/preparation.c +412 -0
- data/ext/link_grammar/link-grammar/preparation.h +20 -0
- data/ext/link_grammar/link-grammar/print-util.c +87 -0
- data/ext/link_grammar/link-grammar/print-util.h +32 -0
- data/ext/link_grammar/link-grammar/print.c +1085 -0
- data/ext/link_grammar/link-grammar/print.h +16 -0
- data/ext/link_grammar/link-grammar/prune.c +1864 -0
- data/ext/link_grammar/link-grammar/prune.h +17 -0
- data/ext/link_grammar/link-grammar/read-dict.c +1785 -0
- data/ext/link_grammar/link-grammar/read-dict.h +29 -0
- data/ext/link_grammar/link-grammar/read-regex.c +161 -0
- data/ext/link_grammar/link-grammar/read-regex.h +12 -0
- data/ext/link_grammar/link-grammar/regex-morph.c +126 -0
- data/ext/link_grammar/link-grammar/regex-morph.h +17 -0
- data/ext/link_grammar/link-grammar/resources.c +180 -0
- data/ext/link_grammar/link-grammar/resources.h +23 -0
- data/ext/link_grammar/link-grammar/sat-solver/.DS_Store +0 -0
- data/ext/link_grammar/link-grammar/sat-solver/.deps/fast-sprintf.Plo +1 -0
- data/ext/link_grammar/link-grammar/sat-solver/.deps/sat-encoder.Plo +1 -0
- data/ext/link_grammar/link-grammar/sat-solver/.deps/util.Plo +1 -0
- data/ext/link_grammar/link-grammar/sat-solver/.deps/variables.Plo +1 -0
- data/ext/link_grammar/link-grammar/sat-solver/.deps/word-tag.Plo +1 -0
- data/ext/link_grammar/link-grammar/sat-solver/Makefile +527 -0
- data/ext/link_grammar/link-grammar/sat-solver/Makefile.am +29 -0
- data/ext/link_grammar/link-grammar/sat-solver/Makefile.in +527 -0
- data/ext/link_grammar/link-grammar/sat-solver/clock.hpp +33 -0
- data/ext/link_grammar/link-grammar/sat-solver/fast-sprintf.cpp +26 -0
- data/ext/link_grammar/link-grammar/sat-solver/fast-sprintf.hpp +7 -0
- data/ext/link_grammar/link-grammar/sat-solver/guiding.hpp +244 -0
- data/ext/link_grammar/link-grammar/sat-solver/matrix-ut.hpp +79 -0
- data/ext/link_grammar/link-grammar/sat-solver/sat-encoder.cpp +2811 -0
- data/ext/link_grammar/link-grammar/sat-solver/sat-encoder.h +11 -0
- data/ext/link_grammar/link-grammar/sat-solver/sat-encoder.hpp +381 -0
- data/ext/link_grammar/link-grammar/sat-solver/trie.hpp +118 -0
- data/ext/link_grammar/link-grammar/sat-solver/util.cpp +23 -0
- data/ext/link_grammar/link-grammar/sat-solver/util.hpp +14 -0
- data/ext/link_grammar/link-grammar/sat-solver/variables.cpp +5 -0
- data/ext/link_grammar/link-grammar/sat-solver/variables.hpp +829 -0
- data/ext/link_grammar/link-grammar/sat-solver/word-tag.cpp +159 -0
- data/ext/link_grammar/link-grammar/sat-solver/word-tag.hpp +162 -0
- data/ext/link_grammar/link-grammar/spellcheck-aspell.c +148 -0
- data/ext/link_grammar/link-grammar/spellcheck-hun.c +136 -0
- data/ext/link_grammar/link-grammar/spellcheck.h +34 -0
- data/ext/link_grammar/link-grammar/string-set.c +169 -0
- data/ext/link_grammar/link-grammar/string-set.h +16 -0
- data/ext/link_grammar/link-grammar/structures.h +498 -0
- data/ext/link_grammar/link-grammar/tokenize.c +1049 -0
- data/ext/link_grammar/link-grammar/tokenize.h +15 -0
- data/ext/link_grammar/link-grammar/utilities.c +847 -0
- data/ext/link_grammar/link-grammar/utilities.h +281 -0
- data/ext/link_grammar/link-grammar/word-file.c +124 -0
- data/ext/link_grammar/link-grammar/word-file.h +15 -0
- data/ext/link_grammar/link-grammar/word-utils.c +526 -0
- data/ext/link_grammar/link-grammar/word-utils.h +152 -0
- data/ext/link_grammar/link_grammar.c +202 -0
- data/ext/link_grammar/link_grammar.h +99 -0
- data/grammar_cop.gemspec +24 -0
- data/lib/.DS_Store +0 -0
- data/lib/grammar_cop.rb +9 -0
- data/lib/grammar_cop/.DS_Store +0 -0
- data/lib/grammar_cop/dictionary.rb +19 -0
- data/lib/grammar_cop/linkage.rb +30 -0
- data/lib/grammar_cop/parse_options.rb +32 -0
- data/lib/grammar_cop/sentence.rb +36 -0
- data/lib/grammar_cop/version.rb +3 -0
- data/test/.DS_Store +0 -0
- data/test/grammar_cop_test.rb +27 -0
- metadata +407 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
/*************************************************************************/
|
2
|
+
/* Copyright (c) 2004 */
|
3
|
+
/* Daniel Sleator, David Temperley, and John Lafferty */
|
4
|
+
/* All rights reserved */
|
5
|
+
/* */
|
6
|
+
/* Use of the link grammar parsing system is subject to the terms of the */
|
7
|
+
/* license set forth in the LICENSE file included with this software, */
|
8
|
+
/* and also available at http://www.link.cs.cmu.edu/link/license.html */
|
9
|
+
/* This license allows free redistribution and use in source and binary */
|
10
|
+
/* forms, with or without modification, subject to certain conditions. */
|
11
|
+
/* */
|
12
|
+
/*************************************************************************/
|
13
|
+
|
14
|
+
#include "api-types.h"
|
15
|
+
#include "structures.h"
|
16
|
+
|
17
|
+
void build_sentence_disjuncts(Sentence sent, float cost_cutoff);
|
18
|
+
X_node * build_word_expressions(Dictionary dict, const char *);
|
19
|
+
Disjunct * build_disjuncts_for_dict_node(Dict_node *);
|
20
|
+
Disjunct * build_disjuncts_for_X_node(X_node * x, float cost_cutoff);
|
21
|
+
|
@@ -0,0 +1,458 @@
|
|
1
|
+
/*************************************************************************/
|
2
|
+
/* Copyright (c) 2004 */
|
3
|
+
/* Daniel Sleator, David Temperley, and John Lafferty */
|
4
|
+
/* Copyright (c) 2008, 2009, 2011 Linas Vepstas */
|
5
|
+
/* All rights reserved */
|
6
|
+
/* */
|
7
|
+
/* Use of the link grammar parsing system is subject to the terms of the */
|
8
|
+
/* license set forth in the LICENSE file included with this software, */
|
9
|
+
/* and also available at http://www.link.cs.cmu.edu/link/license.html */
|
10
|
+
/* This license allows free redistribution and use in source and binary */
|
11
|
+
/* forms, with or without modification, subject to certain conditions. */
|
12
|
+
/* */
|
13
|
+
/*************************************************************************/
|
14
|
+
|
15
|
+
#include <wchar.h>
|
16
|
+
#include <wctype.h>
|
17
|
+
#include <link-grammar/api.h>
|
18
|
+
#include "utilities.h" // For MSWindows portability
|
19
|
+
|
20
|
+
static struct
|
21
|
+
{
|
22
|
+
int verbosity;
|
23
|
+
int timeout;
|
24
|
+
int memory;
|
25
|
+
int linkage_limit;
|
26
|
+
int null_block;
|
27
|
+
int islands_ok;
|
28
|
+
int spell_guess;
|
29
|
+
int short_length;
|
30
|
+
int batch_mode;
|
31
|
+
int panic_mode;
|
32
|
+
int allow_null;
|
33
|
+
int use_cluster_disjuncts;
|
34
|
+
int use_fat_links;
|
35
|
+
int use_sat_solver;
|
36
|
+
int echo_on;
|
37
|
+
int cost_model;
|
38
|
+
float max_cost;
|
39
|
+
int screen_width;
|
40
|
+
int display_on;
|
41
|
+
int display_constituents;
|
42
|
+
int max_sentence_length;
|
43
|
+
int display_postscript;
|
44
|
+
int display_bad;
|
45
|
+
int display_links;
|
46
|
+
int display_walls;
|
47
|
+
int display_union;
|
48
|
+
int display_disjuncts;
|
49
|
+
int display_senses;
|
50
|
+
} local;
|
51
|
+
|
52
|
+
typedef enum
|
53
|
+
{
|
54
|
+
Int,
|
55
|
+
Bool,
|
56
|
+
Float,
|
57
|
+
} ParamType;
|
58
|
+
|
59
|
+
typedef struct
|
60
|
+
{
|
61
|
+
const char *string;
|
62
|
+
ParamType param_type;
|
63
|
+
const char *description;
|
64
|
+
void *ptr;
|
65
|
+
} Switch;
|
66
|
+
|
67
|
+
static Switch default_switches[] =
|
68
|
+
{
|
69
|
+
{"bad", Bool, "Display of bad linkages", &local.display_bad},
|
70
|
+
{"batch", Bool, "Batch mode", &local.batch_mode},
|
71
|
+
{"cluster", Bool, "Use clusters to loosen parsing", &local.use_cluster_disjuncts},
|
72
|
+
{"constituents", Int, "Generate constituent output", &local.display_constituents},
|
73
|
+
{"cost-model", Int, "Cost model used for ranking", &local.cost_model},
|
74
|
+
{"cost-max", Float, "Largest cost to be considered", &local.max_cost},
|
75
|
+
{"disjuncts", Bool, "Display of disjunct used", &local.display_disjuncts},
|
76
|
+
{"echo", Bool, "Echoing of input sentence", &local.echo_on},
|
77
|
+
{"graphics", Bool, "Graphical display of linkage", &local.display_on},
|
78
|
+
{"islands-ok", Bool, "Use of null-linked islands", &local.islands_ok},
|
79
|
+
{"limit", Int, "The maximum linkages processed", &local.linkage_limit},
|
80
|
+
{"links", Bool, "Display of complete link data", &local.display_links},
|
81
|
+
{"max-length", Int, "Maximum sentence length", &local.max_sentence_length},
|
82
|
+
{"memory", Int, "Max memory allowed", &local.memory},
|
83
|
+
{"null", Bool, "Allow null links", &local.allow_null},
|
84
|
+
{"null-block", Int, "Size of blocks with null count 1", &local.null_block},
|
85
|
+
{"panic", Bool, "Use of \"panic mode\"", &local.panic_mode},
|
86
|
+
{"postscript", Bool, "Generate postscript output", &local.display_postscript},
|
87
|
+
{"senses", Bool, "Display of word senses", &local.display_senses},
|
88
|
+
{"short", Int, "Max length of short links", &local.short_length},
|
89
|
+
#if defined HAVE_HUNSPELL || defined HAVE_ASPELL
|
90
|
+
{"spell", Bool, "Use spell-guesser for unknown words", &local.spell_guess},
|
91
|
+
#endif /* HAVE_HUNSPELL */
|
92
|
+
{"timeout", Int, "Abort parsing after this many seconds", &local.timeout},
|
93
|
+
{"union", Bool, "Display of 'union' linkage", &local.display_union},
|
94
|
+
{"use-fat", Bool, "Use fat links when parsing", &local.use_fat_links},
|
95
|
+
#ifdef USE_SAT_SOLVER
|
96
|
+
{"use-sat", Bool, "Use Boolean SAT-based parser", &local.use_sat_solver},
|
97
|
+
#endif /* USE_SAT_SOLVER */
|
98
|
+
{"verbosity", Int, "Level of detail in output", &local.verbosity},
|
99
|
+
{"walls", Bool, "Display wall words", &local.display_walls},
|
100
|
+
{"width", Int, "The width of the display", &local.screen_width},
|
101
|
+
{NULL, Bool, NULL, NULL}
|
102
|
+
};
|
103
|
+
|
104
|
+
struct {const char * s; const char * str;} user_command[] =
|
105
|
+
{
|
106
|
+
{"variables", "List user-settable variables and their functions"},
|
107
|
+
{"help", "List the commands and what they do"},
|
108
|
+
{"file", "Read input from the specified filename"},
|
109
|
+
{NULL, NULL}
|
110
|
+
};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Gets rid of all the white space in the string s. Changes s
|
114
|
+
*/
|
115
|
+
static void clean_up_string(char * s)
|
116
|
+
{
|
117
|
+
char * x, * y;
|
118
|
+
wchar_t p;
|
119
|
+
size_t len, w;
|
120
|
+
mbstate_t state;
|
121
|
+
memset (&state, 0, sizeof(mbstate_t));
|
122
|
+
|
123
|
+
len = strlen(s);
|
124
|
+
y = x = s;
|
125
|
+
while(*x != '\0')
|
126
|
+
{
|
127
|
+
w = mbrtowc(&p, x, len, &state);
|
128
|
+
if (0 == w) break;
|
129
|
+
len -= w;
|
130
|
+
|
131
|
+
if (!iswspace(p)) {
|
132
|
+
while(w) { *y = *x; x++; y++; w--; }
|
133
|
+
} else {
|
134
|
+
x += w;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
*y = '\0';
|
138
|
+
}
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Return TRUE if s points to a number:
|
142
|
+
* optional + or - followed by 1 or more
|
143
|
+
* digits.
|
144
|
+
*/
|
145
|
+
static int is_numerical_rhs(char *s)
|
146
|
+
{
|
147
|
+
wchar_t p;
|
148
|
+
size_t len, w;
|
149
|
+
mbstate_t state;
|
150
|
+
memset (&state, 0, sizeof(mbstate_t));
|
151
|
+
|
152
|
+
len = strlen(s);
|
153
|
+
|
154
|
+
if (*s=='+' || *s == '-') s++;
|
155
|
+
if (*s == '\0') return FALSE;
|
156
|
+
|
157
|
+
for (; *s != '\0'; s+=w)
|
158
|
+
{
|
159
|
+
w = mbrtowc(&p, s, len, &state);
|
160
|
+
if (0 == w) break;
|
161
|
+
len -= w;
|
162
|
+
if(!iswdigit(p)) return FALSE;
|
163
|
+
}
|
164
|
+
return TRUE;
|
165
|
+
}
|
166
|
+
|
167
|
+
static inline int ival(Switch s)
|
168
|
+
{
|
169
|
+
return *((int *) s.ptr);
|
170
|
+
}
|
171
|
+
|
172
|
+
static inline void setival(Switch s, int val)
|
173
|
+
{
|
174
|
+
*((int *) s.ptr) = val;
|
175
|
+
}
|
176
|
+
|
177
|
+
static int x_issue_special_command(const char * line, Parse_Options opts, Dictionary dict)
|
178
|
+
{
|
179
|
+
char *s, myline[1000], *x, *y;
|
180
|
+
int i, count, j, k;
|
181
|
+
Switch * as = default_switches;
|
182
|
+
|
183
|
+
strncpy(myline, line, sizeof(myline));
|
184
|
+
myline[sizeof(myline)-1] = '\0';
|
185
|
+
clean_up_string(myline);
|
186
|
+
|
187
|
+
s = myline;
|
188
|
+
j = k = -1;
|
189
|
+
count = 0;
|
190
|
+
|
191
|
+
/* Look for boolean flippers */
|
192
|
+
for (i=0; as[i].string != NULL; i++)
|
193
|
+
{
|
194
|
+
if ((Bool == as[i].param_type) &&
|
195
|
+
strncasecmp(s, as[i].string, strlen(s)) == 0)
|
196
|
+
{
|
197
|
+
count++;
|
198
|
+
j = i;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
/* Look for abbreviations */
|
203
|
+
for (i=0; user_command[i].s != NULL; i++)
|
204
|
+
{
|
205
|
+
if (strncasecmp(s, user_command[i].s, strlen(s)) == 0)
|
206
|
+
{
|
207
|
+
count++;
|
208
|
+
k = i;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
if (count > 1)
|
213
|
+
{
|
214
|
+
printf("Ambiguous command. Type \"!help\" or \"!variables\"\n");
|
215
|
+
return -1;
|
216
|
+
}
|
217
|
+
else if (count == 1)
|
218
|
+
{
|
219
|
+
/* flip boolean value */
|
220
|
+
if (j >= 0)
|
221
|
+
{
|
222
|
+
setival(as[j], (0 == ival(as[j])));
|
223
|
+
printf("%s turned %s.\n", as[j].description, (ival(as[j]))? "on" : "off");
|
224
|
+
return 0;
|
225
|
+
}
|
226
|
+
else
|
227
|
+
{
|
228
|
+
/* Found an abbreviated command, but it wasn't a boolean */
|
229
|
+
/* Replace the abbreviated command by the full one */
|
230
|
+
/* Basically, this just fixes !v and !h for use below. */
|
231
|
+
strcpy(s, user_command[k].s);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
if (strcmp(s, "variables") == 0)
|
236
|
+
{
|
237
|
+
printf(" Variable Controls Value\n");
|
238
|
+
printf(" -------- -------- -----\n");
|
239
|
+
for (i = 0; as[i].string != NULL; i++)
|
240
|
+
{
|
241
|
+
printf(" ");
|
242
|
+
left_print_string(stdout, as[i].string, " ");
|
243
|
+
left_print_string(stdout, as[i].description,
|
244
|
+
" ");
|
245
|
+
if (Float == as[i].param_type)
|
246
|
+
{
|
247
|
+
/* Float point print! */
|
248
|
+
printf("%5.2f", (double) (*((float *)as[i].ptr)));
|
249
|
+
}
|
250
|
+
else
|
251
|
+
{
|
252
|
+
printf("%5d", ival(as[i]));
|
253
|
+
}
|
254
|
+
if (Bool == as[i].param_type)
|
255
|
+
{
|
256
|
+
if (ival(as[i])) printf(" (On)"); else printf(" (Off)");
|
257
|
+
}
|
258
|
+
printf("\n");
|
259
|
+
}
|
260
|
+
printf("\n");
|
261
|
+
printf("Toggle a boolean variable as in \"!batch\"; ");
|
262
|
+
printf("set a variable as in \"!width=100\".\n");
|
263
|
+
return 0;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (strcmp(s, "help") == 0)
|
267
|
+
{
|
268
|
+
printf("Special commands always begin with \"!\". Command and variable names\n");
|
269
|
+
printf("can be abbreviated. Here is a list of the commands:\n\n");
|
270
|
+
for (i=0; user_command[i].s != NULL; i++) {
|
271
|
+
printf(" !");
|
272
|
+
left_print_string(stdout, user_command[i].s, " ");
|
273
|
+
left_print_string(stdout, user_command[i].str, " ");
|
274
|
+
printf("\n");
|
275
|
+
}
|
276
|
+
printf(" !!<string> Print all the dictionary words matching <string>.\n");
|
277
|
+
printf(" Also print the number of disjuncts of each.\n");
|
278
|
+
printf("\n");
|
279
|
+
printf(" !<var> Toggle the specified boolean variable.\n");
|
280
|
+
printf(" !<var>=<val> Assign that value to that variable.\n");
|
281
|
+
return 0;
|
282
|
+
}
|
283
|
+
|
284
|
+
if (s[0] == '!')
|
285
|
+
{
|
286
|
+
dict_display_word_info(dict, s+1);
|
287
|
+
dict_display_word_expr(dict, s+1);
|
288
|
+
return 0;
|
289
|
+
}
|
290
|
+
|
291
|
+
/* Test here for an equation i.e. does the command line hold an equals sign? */
|
292
|
+
for (x=s; (*x != '=') && (*x != '\0') ; x++)
|
293
|
+
;
|
294
|
+
if (*x == '=')
|
295
|
+
{
|
296
|
+
*x = '\0';
|
297
|
+
y = x+1;
|
298
|
+
x = s;
|
299
|
+
/* now x is the first word and y is the rest */
|
300
|
+
|
301
|
+
/* Figure out which command it is .. it'll be the j'th one */
|
302
|
+
j = -1;
|
303
|
+
for (i=0; as[i].string != NULL; i++)
|
304
|
+
{
|
305
|
+
if (strncasecmp(x, as[i].string, strlen(x)) == 0)
|
306
|
+
{
|
307
|
+
j = i;
|
308
|
+
count ++;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
if (j<0)
|
313
|
+
{
|
314
|
+
printf("There is no user variable called \"%s\".\n", x);
|
315
|
+
return -1;
|
316
|
+
}
|
317
|
+
|
318
|
+
if (count > 1)
|
319
|
+
{
|
320
|
+
printf("Ambiguous variable. Type \"!help\" or \"!variables\"\n");
|
321
|
+
return -1;
|
322
|
+
}
|
323
|
+
|
324
|
+
if (as[j].param_type != Float)
|
325
|
+
{
|
326
|
+
int val = -1;
|
327
|
+
if (is_numerical_rhs(y)) val = atoi(y);
|
328
|
+
|
329
|
+
if ((0 == strcasecmp(y, "true")) || (0 == strcasecmp(y, "t"))) val = 1;
|
330
|
+
if ((0 == strcasecmp(y, "false")) || (0 == strcasecmp(y, "f"))) val = 0;
|
331
|
+
|
332
|
+
if (val < 0)
|
333
|
+
{
|
334
|
+
printf("Invalid value %s for variable %s Type \"!help\" or \"!variables\"\n", y, as[j].string);
|
335
|
+
return -1;
|
336
|
+
}
|
337
|
+
|
338
|
+
setival(as[j], val);
|
339
|
+
printf("%s set to %d\n", as[j].string, val);
|
340
|
+
return 0;
|
341
|
+
}
|
342
|
+
else
|
343
|
+
{
|
344
|
+
float val = -1.0;
|
345
|
+
val = atof(y);
|
346
|
+
if (val < 0.0f)
|
347
|
+
{
|
348
|
+
printf("Invalid value %s for variable %s Type \"!help\" or \"!variables\"\n", y, as[j].string);
|
349
|
+
return -1;
|
350
|
+
}
|
351
|
+
|
352
|
+
*((float *) as[j].ptr) = val;
|
353
|
+
printf("%s set to %5.2f\n", as[j].string, val);
|
354
|
+
return 0;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
/* Look for valid commands, but ones that needed an argument */
|
359
|
+
j = -1;
|
360
|
+
count = 0;
|
361
|
+
for (i = 0; as[i].string != NULL; i++)
|
362
|
+
{
|
363
|
+
if ((Bool != as[i].param_type) &&
|
364
|
+
strncasecmp(s, as[i].string, strlen(s)) == 0)
|
365
|
+
{
|
366
|
+
j = i;
|
367
|
+
count++;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
if (0 < count)
|
372
|
+
{
|
373
|
+
printf("Variable \"%s\" requires a value. Try \"!help\".\n", as[j].string);
|
374
|
+
return -1;
|
375
|
+
}
|
376
|
+
|
377
|
+
printf("I can't interpret \"%s\" as a command. Try \"!help\".\n", myline);
|
378
|
+
return -1;
|
379
|
+
}
|
380
|
+
|
381
|
+
static void put_opts_in_local_vars(Parse_Options opts)
|
382
|
+
{
|
383
|
+
local.verbosity = parse_options_get_verbosity(opts);
|
384
|
+
local.timeout = parse_options_get_max_parse_time(opts);;
|
385
|
+
local.memory = parse_options_get_max_memory(opts);;
|
386
|
+
local.linkage_limit = parse_options_get_linkage_limit(opts);
|
387
|
+
local.null_block = parse_options_get_null_block(opts);
|
388
|
+
local.islands_ok = parse_options_get_islands_ok(opts);
|
389
|
+
local.spell_guess = parse_options_get_spell_guess(opts);
|
390
|
+
local.short_length = parse_options_get_short_length(opts);
|
391
|
+
local.cost_model = parse_options_get_cost_model_type(opts);
|
392
|
+
local.max_cost = parse_options_get_disjunct_costf(opts);
|
393
|
+
local.echo_on = parse_options_get_echo_on(opts);
|
394
|
+
local.batch_mode = parse_options_get_batch_mode(opts);
|
395
|
+
local.panic_mode = parse_options_get_panic_mode(opts);
|
396
|
+
local.screen_width = parse_options_get_screen_width(opts);
|
397
|
+
local.allow_null = parse_options_get_allow_null(opts);
|
398
|
+
local.use_cluster_disjuncts = parse_options_get_use_cluster_disjuncts(opts);
|
399
|
+
local.use_fat_links = parse_options_get_use_fat_links(opts);
|
400
|
+
local.use_sat_solver = parse_options_get_use_sat_parser(opts);
|
401
|
+
local.screen_width = parse_options_get_screen_width(opts);
|
402
|
+
local.display_on = parse_options_get_display_on(opts);
|
403
|
+
local.display_postscript = parse_options_get_display_postscript(opts);
|
404
|
+
local.display_constituents = parse_options_get_display_constituents(opts);
|
405
|
+
local.max_sentence_length = parse_options_get_max_sentence_length(opts);
|
406
|
+
local.display_bad = parse_options_get_display_bad(opts);
|
407
|
+
local.display_disjuncts = parse_options_get_display_disjuncts(opts);
|
408
|
+
local.display_links = parse_options_get_display_links(opts);
|
409
|
+
local.display_senses = parse_options_get_display_senses(opts);
|
410
|
+
local.display_walls = parse_options_get_display_walls(opts);
|
411
|
+
local.display_union = parse_options_get_display_union(opts);
|
412
|
+
}
|
413
|
+
|
414
|
+
static void put_local_vars_in_opts(Parse_Options opts)
|
415
|
+
{
|
416
|
+
parse_options_set_verbosity(opts, local.verbosity);
|
417
|
+
parse_options_set_max_parse_time(opts, local.timeout);
|
418
|
+
parse_options_set_max_memory(opts, local.memory);
|
419
|
+
parse_options_set_linkage_limit(opts, local.linkage_limit);
|
420
|
+
parse_options_set_null_block(opts, local.null_block);
|
421
|
+
parse_options_set_islands_ok(opts, local.islands_ok);
|
422
|
+
parse_options_set_spell_guess(opts, local.spell_guess);
|
423
|
+
parse_options_set_short_length(opts, local.short_length);
|
424
|
+
parse_options_set_echo_on(opts, local.echo_on);
|
425
|
+
parse_options_set_cost_model_type(opts, local.cost_model);
|
426
|
+
parse_options_set_disjunct_costf(opts, local.max_cost);
|
427
|
+
parse_options_set_batch_mode(opts, local.batch_mode);
|
428
|
+
parse_options_set_panic_mode(opts, local.panic_mode);
|
429
|
+
parse_options_set_screen_width(opts, local.screen_width);
|
430
|
+
parse_options_set_allow_null(opts, local.allow_null);
|
431
|
+
parse_options_set_use_cluster_disjuncts(opts, local.use_cluster_disjuncts);
|
432
|
+
parse_options_set_use_fat_links(opts, local.use_fat_links);
|
433
|
+
#ifdef USE_SAT_SOLVER
|
434
|
+
parse_options_set_use_sat_parser(opts, local.use_sat_solver);
|
435
|
+
#endif
|
436
|
+
parse_options_set_screen_width(opts, local.screen_width);
|
437
|
+
parse_options_set_display_on(opts, local.display_on);
|
438
|
+
parse_options_set_display_postscript(opts, local.display_postscript);
|
439
|
+
parse_options_set_display_constituents(opts, local.display_constituents);
|
440
|
+
parse_options_set_max_sentence_length(opts, local.max_sentence_length);
|
441
|
+
parse_options_set_display_bad(opts, local.display_bad);
|
442
|
+
parse_options_set_display_disjuncts(opts, local.display_disjuncts);
|
443
|
+
parse_options_set_display_links(opts, local.display_links);
|
444
|
+
parse_options_set_display_senses(opts, local.display_senses);
|
445
|
+
parse_options_set_display_walls(opts, local.display_walls);
|
446
|
+
parse_options_set_display_union(opts, local.display_union);
|
447
|
+
}
|
448
|
+
|
449
|
+
int issue_special_command(const char * line, Parse_Options opts, Dictionary dict)
|
450
|
+
{
|
451
|
+
int rc;
|
452
|
+
put_opts_in_local_vars(opts);
|
453
|
+
rc = x_issue_special_command(line, opts, dict);
|
454
|
+
put_local_vars_in_opts(opts);
|
455
|
+
return rc;
|
456
|
+
}
|
457
|
+
|
458
|
+
|