grammar_cop 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,20 @@
|
|
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
|
+
void free_sentence_expressions(Sentence sent);
|
14
|
+
void free_sentence_disjuncts(Sentence sent);
|
15
|
+
void free_deletable(Sentence sent);
|
16
|
+
void free_effective_dist(Sentence sent);
|
17
|
+
void prepare_to_parse(Sentence sent, Parse_Options opts);
|
18
|
+
void install_fat_connectors(Sentence sent);
|
19
|
+
void build_deletable(Sentence sent, int has_conjunction);
|
20
|
+
void build_effective_dist(Sentence sent, int has_conjunction);
|
@@ -0,0 +1,87 @@
|
|
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 <stdarg.h>
|
15
|
+
#include "api.h"
|
16
|
+
#include "utilities.h"
|
17
|
+
|
18
|
+
/* This is a "safe" append function, used here to build up a link diagram
|
19
|
+
incrementally. Because the diagram is built up a few characters at
|
20
|
+
a time, we keep around a pointer to the end of string to prevent
|
21
|
+
the algorithm from being quadratic. */
|
22
|
+
|
23
|
+
struct String_s
|
24
|
+
{
|
25
|
+
size_t allocated; /* Unsigned so VC++ doesn't complain about comparisons */
|
26
|
+
size_t eos; /* offset to end of string */
|
27
|
+
char * p;
|
28
|
+
};
|
29
|
+
|
30
|
+
String * string_new(void)
|
31
|
+
{
|
32
|
+
#define INITSZ 30
|
33
|
+
String * string;
|
34
|
+
string = (String *) exalloc(sizeof(String));
|
35
|
+
string->allocated = INITSZ;
|
36
|
+
string->p = (char *) exalloc(INITSZ*sizeof(char));
|
37
|
+
string->p[0] = '\0';
|
38
|
+
string->eos = 0;
|
39
|
+
return string;
|
40
|
+
}
|
41
|
+
|
42
|
+
void string_delete(String *s)
|
43
|
+
{
|
44
|
+
exfree(s->p, s->allocated*sizeof(char));
|
45
|
+
exfree(s, sizeof(String));
|
46
|
+
}
|
47
|
+
|
48
|
+
char * string_copy(String *s)
|
49
|
+
{
|
50
|
+
char * p = (char *) exalloc(s->eos + 1);
|
51
|
+
strcpy(p, s->p);
|
52
|
+
return p;
|
53
|
+
}
|
54
|
+
|
55
|
+
void append_string(String * string, const char *fmt, ...)
|
56
|
+
{
|
57
|
+
#define TMPLEN 1024
|
58
|
+
char temp_string[TMPLEN];
|
59
|
+
size_t templen;
|
60
|
+
char * p;
|
61
|
+
size_t new_size;
|
62
|
+
va_list args;
|
63
|
+
|
64
|
+
va_start(args, fmt);
|
65
|
+
templen = vsnprintf(temp_string, TMPLEN, fmt, args);
|
66
|
+
va_end(args);
|
67
|
+
|
68
|
+
if (string->allocated <= string->eos + templen)
|
69
|
+
{
|
70
|
+
new_size = 2 * string->allocated + templen + 1;
|
71
|
+
p = (char *) exalloc(sizeof(char)*new_size);
|
72
|
+
strcpy(p, string->p);
|
73
|
+
strcpy(p + string->eos, temp_string);
|
74
|
+
|
75
|
+
exfree(string->p, sizeof(char)*string->allocated);
|
76
|
+
|
77
|
+
string->p = p;
|
78
|
+
string->allocated = new_size;
|
79
|
+
string->eos += templen;
|
80
|
+
}
|
81
|
+
else
|
82
|
+
{
|
83
|
+
strcpy(string->p + string->eos, temp_string);
|
84
|
+
string->eos += templen;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
@@ -0,0 +1,32 @@
|
|
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
|
+
#ifndef _PRINTUTILH_
|
14
|
+
#define _PRINTUTILH_
|
15
|
+
|
16
|
+
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
|
17
|
+
#define GNUC_PRINTF( format_idx, arg_idx ) \
|
18
|
+
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
|
19
|
+
#else
|
20
|
+
#define GNUC_PRINTF( format_idx, arg_idx )
|
21
|
+
#endif
|
22
|
+
|
23
|
+
typedef struct String_s String;
|
24
|
+
|
25
|
+
String * string_new(void);
|
26
|
+
void string_delete(String *);
|
27
|
+
char * string_copy(String *);
|
28
|
+
void append_string(String * string, const char *fmt, ...) GNUC_PRINTF(2,3);
|
29
|
+
|
30
|
+
#endif
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,1085 @@
|
|
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
|
+
|
15
|
+
#include <stdarg.h>
|
16
|
+
#include "api.h"
|
17
|
+
#include "corpus/corpus.h"
|
18
|
+
|
19
|
+
const char * trailer(int mode);
|
20
|
+
const char * header(int mode);
|
21
|
+
|
22
|
+
static void set_centers(Linkage linkage, int center[], int print_word_0, int N_words_to_print)
|
23
|
+
{
|
24
|
+
mbstate_t mbss;
|
25
|
+
int i, len, tot;
|
26
|
+
memset(&mbss, 0, sizeof(mbss));
|
27
|
+
|
28
|
+
tot = 0;
|
29
|
+
if (print_word_0) i=0; else i=1;
|
30
|
+
for (; i < N_words_to_print; i++)
|
31
|
+
{
|
32
|
+
/* Centers obtained by counting the characters,
|
33
|
+
* not the bytes in the string.
|
34
|
+
* len = strlen(linkage->word[i]);
|
35
|
+
*/
|
36
|
+
len = mbsrtowcs(NULL, &linkage->word[i], 0, &mbss);
|
37
|
+
center[i] = tot + (len/2);
|
38
|
+
tot += len+1;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
/* the following are all for generating postscript */
|
43
|
+
typedef struct
|
44
|
+
{
|
45
|
+
int N_rows; /* N_rows -- the number of rows */
|
46
|
+
/* tells the height of the links above the sentence */
|
47
|
+
int link_heights[MAX_LINKS];
|
48
|
+
/* the word beginning each row of the display */
|
49
|
+
int row_starts[MAX_SENTENCE];
|
50
|
+
} ps_ctxt_t;
|
51
|
+
|
52
|
+
/**
|
53
|
+
* prints s then prints the last |t|-|s| characters of t.
|
54
|
+
* if s is longer than t, it truncates s.
|
55
|
+
*/
|
56
|
+
static void left_append_string(String * string, const char * s, const char * t) {
|
57
|
+
int i, j, k;
|
58
|
+
j = strlen(t);
|
59
|
+
k = strlen(s);
|
60
|
+
for (i=0; i<j; i++) {
|
61
|
+
if (i<k) {
|
62
|
+
append_string(string, "%c", s[i]);
|
63
|
+
} else {
|
64
|
+
append_string(string, "%c", t[i]);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
static void print_a_link(String * s, Linkage linkage, int link)
|
70
|
+
{
|
71
|
+
Sentence sent = linkage_get_sentence(linkage);
|
72
|
+
Dictionary dict = sent->dict;
|
73
|
+
int l, r;
|
74
|
+
const char *label, *llabel, *rlabel;
|
75
|
+
|
76
|
+
l = linkage_get_link_lword(linkage, link);
|
77
|
+
r = linkage_get_link_rword(linkage, link);
|
78
|
+
label = linkage_get_link_label(linkage, link);
|
79
|
+
llabel = linkage_get_link_llabel(linkage, link);
|
80
|
+
rlabel = linkage_get_link_rlabel(linkage, link);
|
81
|
+
|
82
|
+
if ((l == 0) && dict->left_wall_defined) {
|
83
|
+
left_append_string(s, LEFT_WALL_DISPLAY," ");
|
84
|
+
} else if ((l == (linkage_get_num_words(linkage)-1)) && dict->right_wall_defined) {
|
85
|
+
left_append_string(s, RIGHT_WALL_DISPLAY," ");
|
86
|
+
} else {
|
87
|
+
left_append_string(s, linkage_get_word(linkage, l), " ");
|
88
|
+
}
|
89
|
+
left_append_string(s, llabel, " ");
|
90
|
+
append_string(s, " <---");
|
91
|
+
left_append_string(s, label, "-----");
|
92
|
+
append_string(s, "-> ");
|
93
|
+
left_append_string(s, rlabel, " ");
|
94
|
+
append_string(s, " %s\n", linkage_get_word(linkage, r));
|
95
|
+
}
|
96
|
+
|
97
|
+
|
98
|
+
/**
|
99
|
+
* To the left of each link, print the sequence of domains it is in.
|
100
|
+
* Printing a domain means printing its type.
|
101
|
+
* Takes info from pp_link_array and pp and chosen_words.
|
102
|
+
*/
|
103
|
+
char * linkage_print_links_and_domains(Linkage linkage)
|
104
|
+
{
|
105
|
+
int link, longest, j;
|
106
|
+
int N_links = linkage_get_num_links(linkage);
|
107
|
+
String * s = string_new();
|
108
|
+
char * links_string;
|
109
|
+
const char ** dname;
|
110
|
+
|
111
|
+
longest = 0;
|
112
|
+
for (link=0; link<N_links; link++) {
|
113
|
+
if (linkage_get_link_lword(linkage, link) == -1) continue;
|
114
|
+
if (linkage_get_link_num_domains(linkage, link) > longest)
|
115
|
+
longest = linkage_get_link_num_domains(linkage, link);
|
116
|
+
}
|
117
|
+
for (link=0; link<N_links; link++) {
|
118
|
+
if (linkage_get_link_lword(linkage, link) == -1) continue;
|
119
|
+
dname = linkage_get_link_domain_names(linkage, link);
|
120
|
+
for (j=0; j<linkage_get_link_num_domains(linkage, link); ++j) {
|
121
|
+
append_string(s, " (%s)", dname[j]);
|
122
|
+
}
|
123
|
+
for (;j<longest; j++) {
|
124
|
+
append_string(s, " ");
|
125
|
+
}
|
126
|
+
append_string(s, " ");
|
127
|
+
print_a_link(s, linkage, link);
|
128
|
+
}
|
129
|
+
append_string(s, "\n");
|
130
|
+
if (linkage_get_violation_name(linkage) != NULL) {
|
131
|
+
append_string(s, "P.P. violations:\n");
|
132
|
+
append_string(s, " %s\n\n", linkage_get_violation_name(linkage));
|
133
|
+
}
|
134
|
+
|
135
|
+
links_string = string_copy(s);
|
136
|
+
string_delete(s);
|
137
|
+
return links_string;
|
138
|
+
}
|
139
|
+
|
140
|
+
char * linkage_print_senses(Linkage linkage)
|
141
|
+
{
|
142
|
+
String * s = string_new();
|
143
|
+
char * sense_string;
|
144
|
+
#if USE_CORPUS
|
145
|
+
Linkage_info *lifo = linkage->info;
|
146
|
+
Sense *sns;
|
147
|
+
size_t w, nwords;
|
148
|
+
|
149
|
+
lg_corpus_linkage_senses(linkage);
|
150
|
+
|
151
|
+
nwords = lifo->nwords;
|
152
|
+
for (w=0; w<nwords; w++)
|
153
|
+
{
|
154
|
+
sns = lg_get_word_sense(lifo, w);
|
155
|
+
while (sns)
|
156
|
+
{
|
157
|
+
int idx = lg_sense_get_index(sns);
|
158
|
+
const char * wd = lg_sense_get_subscripted_word(sns);
|
159
|
+
const char * dj = lg_sense_get_disjunct(sns);
|
160
|
+
const char * sense = lg_sense_get_sense(sns);
|
161
|
+
double score = lg_sense_get_score(sns);
|
162
|
+
append_string(s, "%d %s dj=%s sense=%s score=%f\n",
|
163
|
+
idx, wd, dj, sense, score);
|
164
|
+
sns = lg_sense_next(sns);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
#else
|
169
|
+
append_string(s, "Corpus statstics is not enabled in this version\n");
|
170
|
+
#endif
|
171
|
+
sense_string = string_copy(s);
|
172
|
+
string_delete(s);
|
173
|
+
return sense_string;
|
174
|
+
}
|
175
|
+
|
176
|
+
char * linkage_print_disjuncts(Linkage linkage)
|
177
|
+
{
|
178
|
+
double cost, score;
|
179
|
+
const char * infword;
|
180
|
+
const char * dj;
|
181
|
+
char * djs;
|
182
|
+
int w;
|
183
|
+
String * s = string_new();
|
184
|
+
Sentence sent = linkage->sent;
|
185
|
+
int nwords = sent->length;
|
186
|
+
|
187
|
+
/* Decrement nwords, so as to ignore the RIGHT-WALL */
|
188
|
+
nwords --;
|
189
|
+
|
190
|
+
/* Loop over each word in the sentence (skipping LEFT-WALL, which is
|
191
|
+
* word 0. */
|
192
|
+
for (w=1; w<nwords; w++)
|
193
|
+
{
|
194
|
+
Disjunct *disj = linkage->sent->parse_info->chosen_disjuncts[w];
|
195
|
+
if (NULL == disj) continue;
|
196
|
+
|
197
|
+
infword = disj->string;
|
198
|
+
|
199
|
+
dj = linkage_get_disjunct_str(linkage, w);
|
200
|
+
cost = linkage_get_disjunct_cost(linkage, w);
|
201
|
+
|
202
|
+
#if USE_CORPUS
|
203
|
+
score = linkage_get_disjunct_corpus_score(linkage, w);
|
204
|
+
append_string(s, "%21s %5.1f %6.3f %s\n", infword, cost, score, dj);
|
205
|
+
#else
|
206
|
+
append_string(s, "%21s %5.1f %s\n", infword, cost, dj);
|
207
|
+
#endif
|
208
|
+
}
|
209
|
+
djs = string_copy(s);
|
210
|
+
string_delete(s);
|
211
|
+
return djs;
|
212
|
+
}
|
213
|
+
|
214
|
+
/**
|
215
|
+
*/
|
216
|
+
static char * build_linkage_postscript_string(Linkage linkage, ps_ctxt_t *pctx)
|
217
|
+
{
|
218
|
+
int link, i,j;
|
219
|
+
int d;
|
220
|
+
int print_word_0 = 0, print_word_N = 0, N_wall_connectors, suppressor_used;
|
221
|
+
Sublinkage *sublinkage = &(linkage->sublinkage[linkage->current]);
|
222
|
+
int N_links = sublinkage->num_links;
|
223
|
+
Link **ppla = sublinkage->link;
|
224
|
+
String * string;
|
225
|
+
char * ps_string;
|
226
|
+
Dictionary dict = linkage->sent->dict;
|
227
|
+
Parse_Options opts = linkage->opts;
|
228
|
+
int N_words_to_print;
|
229
|
+
|
230
|
+
string = string_new();
|
231
|
+
|
232
|
+
N_wall_connectors = 0;
|
233
|
+
if (dict->left_wall_defined) {
|
234
|
+
suppressor_used = FALSE;
|
235
|
+
if (!opts->display_walls)
|
236
|
+
for (j=0; j<N_links; j++) {
|
237
|
+
if (ppla[j]->l == 0) {
|
238
|
+
if (ppla[j]->r == linkage->num_words-1) continue;
|
239
|
+
N_wall_connectors ++;
|
240
|
+
if (strcmp(ppla[j]->lc->string, LEFT_WALL_SUPPRESS)==0) {
|
241
|
+
suppressor_used = TRUE;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
print_word_0 = (((!suppressor_used) && (N_wall_connectors != 0))
|
246
|
+
|| (N_wall_connectors > 1) || opts->display_walls);
|
247
|
+
} else {
|
248
|
+
print_word_0 = TRUE;
|
249
|
+
}
|
250
|
+
|
251
|
+
N_wall_connectors = 0;
|
252
|
+
if (dict->right_wall_defined) {
|
253
|
+
suppressor_used = FALSE;
|
254
|
+
for (j=0; j<N_links; j++) {
|
255
|
+
if (ppla[j]->r == linkage->num_words-1) {
|
256
|
+
N_wall_connectors ++;
|
257
|
+
if (strcmp(ppla[j]->lc->string, RIGHT_WALL_SUPPRESS)==0){
|
258
|
+
suppressor_used = TRUE;
|
259
|
+
}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
print_word_N = (((!suppressor_used) && (N_wall_connectors != 0))
|
263
|
+
|| (N_wall_connectors > 1) || opts->display_walls);
|
264
|
+
}
|
265
|
+
else {
|
266
|
+
print_word_N = TRUE;
|
267
|
+
}
|
268
|
+
|
269
|
+
if (print_word_0) d=0; else d=1;
|
270
|
+
|
271
|
+
i = 0;
|
272
|
+
N_words_to_print = linkage->num_words;
|
273
|
+
if (!print_word_N) N_words_to_print--;
|
274
|
+
|
275
|
+
append_string(string, "[");
|
276
|
+
for (j=d; j<N_words_to_print; j++) {
|
277
|
+
if ((i%10 == 0) && (i>0)) append_string(string, "\n");
|
278
|
+
i++;
|
279
|
+
append_string(string, "(%s)", linkage->word[j]);
|
280
|
+
}
|
281
|
+
append_string(string,"]");
|
282
|
+
append_string(string,"\n");
|
283
|
+
|
284
|
+
append_string(string,"[");
|
285
|
+
j = 0;
|
286
|
+
for (link=0; link<N_links; link++) {
|
287
|
+
if (!print_word_0 && (ppla[link]->l == 0)) continue;
|
288
|
+
if (!print_word_N && (ppla[link]->r == linkage->num_words-1)) continue;
|
289
|
+
if (ppla[link]->l == -1) continue;
|
290
|
+
if ((j%7 == 0) && (j>0)) append_string(string,"\n");
|
291
|
+
j++;
|
292
|
+
append_string(string,"[%d %d %d",
|
293
|
+
ppla[link]->l-d, ppla[link]->r-d,
|
294
|
+
pctx->link_heights[link]);
|
295
|
+
if (ppla[link]->lc->label < 0) {
|
296
|
+
append_string(string," (%s)]", ppla[link]->name);
|
297
|
+
} else {
|
298
|
+
append_string(string," ()]");
|
299
|
+
}
|
300
|
+
}
|
301
|
+
append_string(string,"]");
|
302
|
+
append_string(string,"\n");
|
303
|
+
append_string(string,"[");
|
304
|
+
for (j=0; j < pctx->N_rows; j++ )
|
305
|
+
{
|
306
|
+
if (j>0) append_string(string, " %d", pctx->row_starts[j]);
|
307
|
+
else append_string(string,"%d", pctx->row_starts[j]);
|
308
|
+
}
|
309
|
+
append_string(string,"]\n");
|
310
|
+
|
311
|
+
ps_string = string_copy(string);
|
312
|
+
string_delete(string);
|
313
|
+
return ps_string;
|
314
|
+
}
|
315
|
+
|
316
|
+
/**
|
317
|
+
* This takes the current chosen_disjuncts array and uses it to
|
318
|
+
* compute the chosen_words array. "I.xx" suffixes are eliminated.
|
319
|
+
*/
|
320
|
+
void compute_chosen_words(Sentence sent, Linkage linkage)
|
321
|
+
{
|
322
|
+
int i, l;
|
323
|
+
const char *t;
|
324
|
+
char * s, *u;
|
325
|
+
Parse_info pi = sent->parse_info;
|
326
|
+
const char * chosen_words[MAX_SENTENCE];
|
327
|
+
Parse_Options opts = linkage->opts;
|
328
|
+
|
329
|
+
for (i=0; i<sent->length; i++)
|
330
|
+
{ /* get rid of those ugly ".Ixx" */
|
331
|
+
chosen_words[i] = sent->word[i].string;
|
332
|
+
if (pi->chosen_disjuncts[i] == NULL) {
|
333
|
+
/* no disjunct is used on this word because of null-links */
|
334
|
+
t = chosen_words[i];
|
335
|
+
l = strlen(t) + 2;
|
336
|
+
s = (char *) xalloc(l+1);
|
337
|
+
sprintf(s, "[%s]", t);
|
338
|
+
t = string_set_add(s, sent->string_set);
|
339
|
+
xfree(s, l+1);
|
340
|
+
chosen_words[i] = t;
|
341
|
+
} else if (opts->display_word_subscripts) {
|
342
|
+
t = pi->chosen_disjuncts[i]->string;
|
343
|
+
if (is_idiom_word(t)) {
|
344
|
+
l = strlen(t);
|
345
|
+
s = (char *) xalloc(l+1);
|
346
|
+
strcpy(s,t);
|
347
|
+
for (u=s; *u != '.'; u++)
|
348
|
+
;
|
349
|
+
*u = '\0';
|
350
|
+
t = string_set_add(s, sent->string_set);
|
351
|
+
xfree(s, l+1);
|
352
|
+
chosen_words[i] = t;
|
353
|
+
} else {
|
354
|
+
chosen_words[i] = t;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
}
|
358
|
+
if (sent->dict->left_wall_defined) {
|
359
|
+
chosen_words[0] = LEFT_WALL_DISPLAY;
|
360
|
+
}
|
361
|
+
if (sent->dict->right_wall_defined) {
|
362
|
+
chosen_words[sent->length-1] = RIGHT_WALL_DISPLAY;
|
363
|
+
}
|
364
|
+
for (i=0; i<linkage->num_words; ++i) {
|
365
|
+
s = (char *) exalloc(strlen(chosen_words[i])+1);
|
366
|
+
strcpy(s, chosen_words[i]);
|
367
|
+
linkage->word[i] = s;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
#define MAX_HEIGHT 30
|
373
|
+
|
374
|
+
/**
|
375
|
+
* String allocated with exalloc.
|
376
|
+
* Needs to be freed with linkage_free_diagram()
|
377
|
+
*/
|
378
|
+
static char * linkage_print_diagram_ctxt(Linkage linkage, ps_ctxt_t *pctx)
|
379
|
+
{
|
380
|
+
int i, j, k, cl, cr, row, top_row, width, flag;
|
381
|
+
const char *s;
|
382
|
+
char *t;
|
383
|
+
int print_word_0 = 0, print_word_N = 0, N_wall_connectors, suppressor_used;
|
384
|
+
int center[MAX_SENTENCE];
|
385
|
+
char connector[MAX_TOKEN_LENGTH];
|
386
|
+
int line_len, link_length;
|
387
|
+
Sublinkage *sublinkage=&(linkage->sublinkage[linkage->current]);
|
388
|
+
int N_links = sublinkage->num_links;
|
389
|
+
Link **ppla = sublinkage->link;
|
390
|
+
String * string;
|
391
|
+
char * gr_string;
|
392
|
+
Dictionary dict = linkage->sent->dict;
|
393
|
+
Parse_Options opts = linkage->opts;
|
394
|
+
int x_screen_width = parse_options_get_screen_width(opts);
|
395
|
+
int N_words_to_print;
|
396
|
+
|
397
|
+
char picture[MAX_HEIGHT][MAX_LINE];
|
398
|
+
char xpicture[MAX_HEIGHT][MAX_LINE];
|
399
|
+
|
400
|
+
|
401
|
+
string = string_new();
|
402
|
+
|
403
|
+
N_wall_connectors = 0;
|
404
|
+
if (dict->left_wall_defined)
|
405
|
+
{
|
406
|
+
suppressor_used = FALSE;
|
407
|
+
if (!opts->display_walls)
|
408
|
+
{
|
409
|
+
for (j=0; j<N_links; j++)
|
410
|
+
{
|
411
|
+
if ((ppla[j]->l == 0))
|
412
|
+
{
|
413
|
+
if (ppla[j]->r == linkage->num_words-1) continue;
|
414
|
+
N_wall_connectors ++;
|
415
|
+
if (strcmp(ppla[j]->lc->string, LEFT_WALL_SUPPRESS)==0)
|
416
|
+
{
|
417
|
+
suppressor_used = TRUE;
|
418
|
+
}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
}
|
422
|
+
print_word_0 = (((!suppressor_used) && (N_wall_connectors != 0))
|
423
|
+
|| (N_wall_connectors > 1) || opts->display_walls);
|
424
|
+
}
|
425
|
+
else
|
426
|
+
{
|
427
|
+
print_word_0 = TRUE;
|
428
|
+
}
|
429
|
+
|
430
|
+
N_wall_connectors = 0;
|
431
|
+
if (dict->right_wall_defined)
|
432
|
+
{
|
433
|
+
suppressor_used = FALSE;
|
434
|
+
for (j=0; j<N_links; j++)
|
435
|
+
{
|
436
|
+
if (ppla[j]->r == linkage->num_words-1)
|
437
|
+
{
|
438
|
+
N_wall_connectors ++;
|
439
|
+
if (strcmp(ppla[j]->lc->string, RIGHT_WALL_SUPPRESS)==0)
|
440
|
+
{
|
441
|
+
suppressor_used = TRUE;
|
442
|
+
}
|
443
|
+
}
|
444
|
+
}
|
445
|
+
print_word_N = (((!suppressor_used) && (N_wall_connectors != 0))
|
446
|
+
|| (N_wall_connectors > 1) || opts->display_walls);
|
447
|
+
}
|
448
|
+
else
|
449
|
+
{
|
450
|
+
print_word_N = TRUE;
|
451
|
+
}
|
452
|
+
|
453
|
+
N_words_to_print = linkage->num_words;
|
454
|
+
if (!print_word_N) N_words_to_print--;
|
455
|
+
|
456
|
+
set_centers(linkage, center, print_word_0, N_words_to_print);
|
457
|
+
line_len = center[N_words_to_print-1]+1;
|
458
|
+
|
459
|
+
for (k=0; k<MAX_HEIGHT; k++) {
|
460
|
+
for (j=0; j<line_len; j++) picture[k][j] = ' ';
|
461
|
+
picture[k][line_len] = '\0';
|
462
|
+
}
|
463
|
+
top_row = 0;
|
464
|
+
|
465
|
+
for (link_length = 1; link_length < N_words_to_print; link_length++) {
|
466
|
+
for (j=0; j<N_links; j++) {
|
467
|
+
if (ppla[j]->l == -1) continue;
|
468
|
+
if ((ppla[j]->r - ppla[j]->l) != link_length)
|
469
|
+
continue;
|
470
|
+
if (!print_word_0 && (ppla[j]->l == 0)) continue;
|
471
|
+
/* gets rid of the irrelevant link to the left wall */
|
472
|
+
if (!print_word_N && (ppla[j]->r == linkage->num_words-1)) continue;
|
473
|
+
/* gets rid of the irrelevant link to the right wall */
|
474
|
+
|
475
|
+
/* put it into the lowest position */
|
476
|
+
cl = center[ppla[j]->l];
|
477
|
+
cr = center[ppla[j]->r];
|
478
|
+
for (row=0; row < MAX_HEIGHT; row++) {
|
479
|
+
for (k=cl+1; k<cr; k++) {
|
480
|
+
if (picture[row][k] != ' ') break;
|
481
|
+
}
|
482
|
+
if (k == cr) break;
|
483
|
+
}
|
484
|
+
/* we know it fits, so put it in this row */
|
485
|
+
|
486
|
+
pctx->link_heights[j] = row;
|
487
|
+
|
488
|
+
if (2*row+2 > MAX_HEIGHT-1) {
|
489
|
+
append_string(string, "The diagram is too high.\n");
|
490
|
+
gr_string = string_copy(string);
|
491
|
+
string_delete(string);
|
492
|
+
return gr_string;
|
493
|
+
}
|
494
|
+
if (row > top_row) top_row = row;
|
495
|
+
|
496
|
+
picture[row][cl] = '+';
|
497
|
+
picture[row][cr] = '+';
|
498
|
+
for (k=cl+1; k<cr; k++) {
|
499
|
+
picture[row][k] = '-';
|
500
|
+
}
|
501
|
+
s = ppla[j]->name;
|
502
|
+
|
503
|
+
if (opts->display_link_subscripts)
|
504
|
+
{
|
505
|
+
if (!is_utf8_alpha(s))
|
506
|
+
s = "";
|
507
|
+
}
|
508
|
+
else
|
509
|
+
{
|
510
|
+
if (!is_utf8_upper(s)) {
|
511
|
+
s = ""; /* Don't print fat link connector name */
|
512
|
+
}
|
513
|
+
}
|
514
|
+
strncpy(connector, s, MAX_TOKEN_LENGTH-1);
|
515
|
+
connector[MAX_TOKEN_LENGTH-1] = '\0';
|
516
|
+
k=0;
|
517
|
+
if (opts->display_link_subscripts)
|
518
|
+
k = strlen(connector);
|
519
|
+
else
|
520
|
+
for (t=connector; isupper((int)*t); t++) k++; /* uppercase len of conn*/
|
521
|
+
if ((cl+cr-k)/2 + 1 <= cl) {
|
522
|
+
t = picture[row] + cl + 1;
|
523
|
+
} else {
|
524
|
+
t = picture[row] + (cl+cr-k)/2 + 1;
|
525
|
+
}
|
526
|
+
s = connector;
|
527
|
+
if (opts->display_link_subscripts)
|
528
|
+
while((*s != '\0') && (*t == '-')) *t++ = *s++;
|
529
|
+
else
|
530
|
+
while(isupper((int)*s) && (*t == '-')) *t++ = *s++;
|
531
|
+
|
532
|
+
/* now put in the | below this one, where needed */
|
533
|
+
for (k=0; k<row; k++) {
|
534
|
+
if (picture[k][cl] == ' ') {
|
535
|
+
picture[k][cl] = '|';
|
536
|
+
}
|
537
|
+
if (picture[k][cr] == ' ') {
|
538
|
+
picture[k][cr] = '|';
|
539
|
+
}
|
540
|
+
}
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
544
|
+
/* we have the link picture, now put in the words and extra "|"s */
|
545
|
+
|
546
|
+
t = xpicture[0];
|
547
|
+
if (print_word_0) k = 0; else k = 1;
|
548
|
+
for (; k<N_words_to_print; k++) {
|
549
|
+
s = linkage->word[k];
|
550
|
+
i=0;
|
551
|
+
while(*s != '\0') {
|
552
|
+
*t++ = *s++;
|
553
|
+
i++;
|
554
|
+
}
|
555
|
+
*t++ = ' ';
|
556
|
+
}
|
557
|
+
*t = '\0';
|
558
|
+
|
559
|
+
if (opts->display_short) {
|
560
|
+
for (k=0; picture[0][k] != '\0'; k++) {
|
561
|
+
if ((picture[0][k] == '+') || (picture[0][k] == '|')) {
|
562
|
+
xpicture[1][k] = '|';
|
563
|
+
} else {
|
564
|
+
xpicture[1][k] = ' ';
|
565
|
+
}
|
566
|
+
}
|
567
|
+
xpicture[1][k] = '\0';
|
568
|
+
for (row=0; row < top_row+1; row++) {
|
569
|
+
strcpy(xpicture[row+2],picture[row]);
|
570
|
+
}
|
571
|
+
top_row = top_row+2;
|
572
|
+
} else {
|
573
|
+
for (row=0; row < top_row+1; row++) {
|
574
|
+
strcpy(xpicture[2*row+2],picture[row]);
|
575
|
+
for (k=0; picture[row][k] != '\0'; k++) {
|
576
|
+
if ((picture[row][k] == '+') || (picture[row][k] == '|')) {
|
577
|
+
xpicture[2*row+1][k] = '|';
|
578
|
+
} else {
|
579
|
+
xpicture[2*row+1][k] = ' ';
|
580
|
+
}
|
581
|
+
}
|
582
|
+
xpicture[2*row+1][k] = '\0';
|
583
|
+
}
|
584
|
+
top_row = 2*top_row + 2;
|
585
|
+
}
|
586
|
+
|
587
|
+
/* we've built the picture, now print it out */
|
588
|
+
|
589
|
+
if (print_word_0) i = 0; else i = 1;
|
590
|
+
k = 0;
|
591
|
+
pctx->N_rows = 0;
|
592
|
+
pctx->row_starts[pctx->N_rows] = 0;
|
593
|
+
pctx->N_rows++;
|
594
|
+
while(i < N_words_to_print) {
|
595
|
+
append_string(string, "\n");
|
596
|
+
width = 0;
|
597
|
+
do {
|
598
|
+
width += strlen(linkage->word[i])+1;
|
599
|
+
i++;
|
600
|
+
} while((i<N_words_to_print) &&
|
601
|
+
(width + ((int)strlen(linkage->word[i]))+1 < x_screen_width));
|
602
|
+
pctx->row_starts[pctx->N_rows] = i - (!print_word_0); /* PS junk */
|
603
|
+
if (i<N_words_to_print) pctx->N_rows++; /* same */
|
604
|
+
for (row = top_row; row >= 0; row--) {
|
605
|
+
flag = TRUE;
|
606
|
+
for (j=k;flag&&(j<k+width)&&(xpicture[row][j]!='\0'); j++){
|
607
|
+
flag = flag && (xpicture[row][j] == ' ');
|
608
|
+
}
|
609
|
+
if (!flag) {
|
610
|
+
for (j=k;(j<k+width)&&(xpicture[row][j]!='\0'); j++){
|
611
|
+
append_string(string, "%c", xpicture[row][j]);
|
612
|
+
}
|
613
|
+
append_string(string, "\n");
|
614
|
+
}
|
615
|
+
}
|
616
|
+
append_string(string, "\n");
|
617
|
+
k += width;
|
618
|
+
}
|
619
|
+
gr_string = string_copy(string);
|
620
|
+
string_delete(string);
|
621
|
+
return gr_string;
|
622
|
+
}
|
623
|
+
|
624
|
+
char * linkage_print_diagram(Linkage linkage)
|
625
|
+
{
|
626
|
+
ps_ctxt_t ctx;
|
627
|
+
return linkage_print_diagram_ctxt(linkage, &ctx);
|
628
|
+
}
|
629
|
+
|
630
|
+
void linkage_free_diagram(char * s)
|
631
|
+
{
|
632
|
+
exfree(s, strlen(s)+1);
|
633
|
+
}
|
634
|
+
|
635
|
+
void linkage_free_disjuncts(char * s)
|
636
|
+
{
|
637
|
+
exfree(s, strlen(s)+1);
|
638
|
+
}
|
639
|
+
|
640
|
+
void linkage_free_links_and_domains(char * s)
|
641
|
+
{
|
642
|
+
exfree(s, strlen(s)+1);
|
643
|
+
}
|
644
|
+
|
645
|
+
void linkage_free_senses(char * s)
|
646
|
+
{
|
647
|
+
exfree(s, strlen(s)+1);
|
648
|
+
}
|
649
|
+
|
650
|
+
char * linkage_print_postscript(Linkage linkage, int mode)
|
651
|
+
{
|
652
|
+
char * ps, * qs;
|
653
|
+
int size;
|
654
|
+
|
655
|
+
/* call the ascii printer to initialize the row size stuff. */
|
656
|
+
ps_ctxt_t ctx;
|
657
|
+
char * ascii = linkage_print_diagram_ctxt(linkage, &ctx);
|
658
|
+
linkage_free_diagram(ascii);
|
659
|
+
|
660
|
+
ps = build_linkage_postscript_string(linkage, &ctx);
|
661
|
+
size = strlen(header(mode)) + strlen(ps) + strlen(trailer(mode)) + 1;
|
662
|
+
|
663
|
+
qs = (char *) exalloc(sizeof(char)*size);
|
664
|
+
sprintf(qs, "%s%s%s", header(mode), ps, trailer(mode));
|
665
|
+
exfree(ps, strlen(ps)+1);
|
666
|
+
|
667
|
+
return qs;
|
668
|
+
}
|
669
|
+
|
670
|
+
void linkage_free_postscript(char * s)
|
671
|
+
{
|
672
|
+
exfree(s, strlen(s)+1);
|
673
|
+
}
|
674
|
+
|
675
|
+
void print_disjunct_counts(Sentence sent) {
|
676
|
+
int i;
|
677
|
+
int c;
|
678
|
+
Disjunct *d;
|
679
|
+
for (i=0; i<sent->length; i++) {
|
680
|
+
c = 0;
|
681
|
+
for (d=sent->word[i].d; d != NULL; d = d->next) {
|
682
|
+
c++;
|
683
|
+
}
|
684
|
+
printf("%s(%d) ",sent->word[i].string, c);
|
685
|
+
}
|
686
|
+
printf("\n\n");
|
687
|
+
}
|
688
|
+
|
689
|
+
void print_expression_sizes(Sentence sent) {
|
690
|
+
X_node * x;
|
691
|
+
int w, size;
|
692
|
+
for (w=0; w<sent->length; w++) {
|
693
|
+
size = 0;
|
694
|
+
for (x=sent->word[w].x; x!=NULL; x = x->next) {
|
695
|
+
size += size_of_expression(x->exp);
|
696
|
+
}
|
697
|
+
printf("%s[%d] ",sent->word[w].string, size);
|
698
|
+
}
|
699
|
+
printf("\n\n");
|
700
|
+
}
|
701
|
+
|
702
|
+
/**
|
703
|
+
* this version just prints it on one line.
|
704
|
+
*/
|
705
|
+
void print_sentence(FILE *fp, Sentence sent, int w)
|
706
|
+
{
|
707
|
+
int i;
|
708
|
+
if (sent->dict->left_wall_defined) i=1; else i=0;
|
709
|
+
for (; i<sent->length - sent->dict->right_wall_defined; i++) {
|
710
|
+
fprintf(fp, "%s ", sent->word[i].string);
|
711
|
+
}
|
712
|
+
fprintf(fp, "\n");
|
713
|
+
}
|
714
|
+
|
715
|
+
const char * trailer(int mode)
|
716
|
+
{
|
717
|
+
static const char * trailer_string=
|
718
|
+
"diagram\n"
|
719
|
+
"\n"
|
720
|
+
"%%EndDocument\n"
|
721
|
+
;
|
722
|
+
|
723
|
+
if (mode==1) return trailer_string;
|
724
|
+
else return "";
|
725
|
+
}
|
726
|
+
|
727
|
+
const char * header(int mode)
|
728
|
+
{
|
729
|
+
static const char * header_string=
|
730
|
+
"%!PS-Adobe-2.0 EPSF-1.2\n"
|
731
|
+
"%%Pages: 1\n"
|
732
|
+
"%%BoundingBox: 0 -20 500 200\n"
|
733
|
+
"%%EndComments\n"
|
734
|
+
"%%BeginDocument: \n"
|
735
|
+
"\n"
|
736
|
+
"% compute size of diagram by adding\n"
|
737
|
+
"% #rows x 8.5\n"
|
738
|
+
"% (#rows -1) x 10\n"
|
739
|
+
"% \\sum maxheight x 10\n"
|
740
|
+
"/nulllink () def % The symbol of a null link\n"
|
741
|
+
"/wordfontsize 11 def % the size of the word font\n"
|
742
|
+
"/labelfontsize 9 def % the size of the connector label font\n"
|
743
|
+
"/ex 10 def % the horizontal radius of all the links\n"
|
744
|
+
"/ey 10 def % the height of the level 0 links\n"
|
745
|
+
"/ed 10 def % amount to add to this height per level\n"
|
746
|
+
"/radius 10 def % radius for rounded arcs\n"
|
747
|
+
"/row-spacing 10 def % the space between successive rows of the diagram\n"
|
748
|
+
"\n"
|
749
|
+
"/gap wordfontsize .5 mul def % the gap between words\n"
|
750
|
+
"/top-of-words wordfontsize .85 mul def\n"
|
751
|
+
" % the delta y above where the text is written where\n"
|
752
|
+
" % the major axis of the ellipse is located\n"
|
753
|
+
"/label-gap labelfontsize .1 mul def\n"
|
754
|
+
"\n"
|
755
|
+
"/xwordfontsize 10 def % the size of the word font\n"
|
756
|
+
"/xlabelfontsize 10 def % the size of the connector label font\n"
|
757
|
+
"/xex 10 def % the horizontal radius of all the links\n"
|
758
|
+
"/xey 10 def % the height of the level 0 links\n"
|
759
|
+
"/xed 10 def % amount to add to this height per level\n"
|
760
|
+
"/xradius 10 def % radius for rounded arcs\n"
|
761
|
+
"/xrow-spacing 10 def % the space between successive rows of the diagram\n"
|
762
|
+
"/xgap wordfontsize .5 mul def % the gap between words\n"
|
763
|
+
"\n"
|
764
|
+
"/centerpage 6.5 72 mul 2 div def\n"
|
765
|
+
" % this number of points from the left margin is the center of page\n"
|
766
|
+
"\n"
|
767
|
+
"/rightpage 6.5 72 mul def\n"
|
768
|
+
" % number of points from the left margin is the the right margin\n"
|
769
|
+
"\n"
|
770
|
+
"/show-string-centered-dict 5 dict def\n"
|
771
|
+
"\n"
|
772
|
+
"/show-string-centered {\n"
|
773
|
+
" show-string-centered-dict begin\n"
|
774
|
+
" /string exch def\n"
|
775
|
+
" /ycenter exch def\n"
|
776
|
+
" /xcenter exch def\n"
|
777
|
+
" xcenter string stringwidth pop 2 div sub\n"
|
778
|
+
" ycenter labelfontsize .3 mul sub\n"
|
779
|
+
" moveto\n"
|
780
|
+
" string show\n"
|
781
|
+
" end\n"
|
782
|
+
"} def\n"
|
783
|
+
"\n"
|
784
|
+
"/clear-word-box {\n"
|
785
|
+
" show-string-centered-dict begin\n"
|
786
|
+
" /string exch def\n"
|
787
|
+
" /ycenter exch def\n"
|
788
|
+
" /xcenter exch def\n"
|
789
|
+
" newpath\n"
|
790
|
+
" /urx string stringwidth pop 2 div def\n"
|
791
|
+
" /ury labelfontsize .3 mul def\n"
|
792
|
+
" xcenter urx sub ycenter ury sub moveto\n"
|
793
|
+
" xcenter urx add ycenter ury sub lineto\n"
|
794
|
+
" xcenter urx add ycenter ury add lineto\n"
|
795
|
+
" xcenter urx sub ycenter ury add lineto\n"
|
796
|
+
" closepath\n"
|
797
|
+
" 1 setgray fill\n"
|
798
|
+
" 0 setgray\n"
|
799
|
+
" end\n"
|
800
|
+
"} def\n"
|
801
|
+
"\n"
|
802
|
+
"/diagram-sentence-dict 20 dict def\n"
|
803
|
+
"\n"
|
804
|
+
"/diagram-sentence-circle\n"
|
805
|
+
"{diagram-sentence-dict begin \n"
|
806
|
+
" /links exch def\n"
|
807
|
+
" /words exch def\n"
|
808
|
+
" /n words length def\n"
|
809
|
+
" /Times-Roman findfont wordfontsize scalefont setfont\n"
|
810
|
+
" /x 0 def\n"
|
811
|
+
" /y 0 def\n"
|
812
|
+
"\n"
|
813
|
+
" /left-ends [x dup words {stringwidth pop add gap add dup}\n"
|
814
|
+
" forall pop pop] def\n"
|
815
|
+
" /right-ends [x words {stringwidth pop add dup gap add} forall pop] def\n"
|
816
|
+
" /centers [0 1 n 1 sub {/i exch def\n"
|
817
|
+
" left-ends i get\n"
|
818
|
+
" right-ends i get\n"
|
819
|
+
" add 2 div\n"
|
820
|
+
" } for ] def\n"
|
821
|
+
"\n"
|
822
|
+
" x y moveto\n"
|
823
|
+
" words {show gap 0 rmoveto} forall\n"
|
824
|
+
"\n"
|
825
|
+
" .5 setlinewidth \n"
|
826
|
+
"\n"
|
827
|
+
" links {dup 0 get /leftword exch def\n"
|
828
|
+
" dup 1 get /rightword exch def\n"
|
829
|
+
" dup 2 get /level exch def\n"
|
830
|
+
" 3 get /string exch def\n"
|
831
|
+
" newpath\n"
|
832
|
+
" string nulllink eq {[2] 1 setdash}{[] 0 setdash} ifelse\n"
|
833
|
+
"% string nulllink eq {.8 setgray}{0 setgray} ifelse\n"
|
834
|
+
" centers leftword get\n"
|
835
|
+
" y top-of-words add\n"
|
836
|
+
" moveto\n"
|
837
|
+
" \n"
|
838
|
+
" centers rightword get\n"
|
839
|
+
" centers leftword get\n"
|
840
|
+
" sub 2 div dup\n"
|
841
|
+
" radius \n"
|
842
|
+
" lt {/radiusx exch def}{pop /radiusx radius def} ifelse\n"
|
843
|
+
" \n"
|
844
|
+
" \n"
|
845
|
+
" \n"
|
846
|
+
" centers leftword get\n"
|
847
|
+
" y top-of-words add ey ed level mul add add\n"
|
848
|
+
" centers rightword get\n"
|
849
|
+
" y top-of-words add ey ed level mul add add\n"
|
850
|
+
" radiusx\n"
|
851
|
+
" arcto\n"
|
852
|
+
" 4 {pop} repeat\n"
|
853
|
+
" centers rightword get\n"
|
854
|
+
" y top-of-words add ey ed level mul add add\n"
|
855
|
+
" centers rightword get\n"
|
856
|
+
" y top-of-words add\n"
|
857
|
+
" radiusx\n"
|
858
|
+
" arcto\n"
|
859
|
+
" 4 {pop} repeat\n"
|
860
|
+
" centers rightword get\n"
|
861
|
+
" y top-of-words add\n"
|
862
|
+
" lineto\n"
|
863
|
+
"\n"
|
864
|
+
" stroke\n"
|
865
|
+
"\n"
|
866
|
+
" /radius-y ey ed level mul add def\n"
|
867
|
+
"\n"
|
868
|
+
" /center-arc-x\n"
|
869
|
+
" centers leftword get centers rightword get add 2 div\n"
|
870
|
+
" def\n"
|
871
|
+
" \n"
|
872
|
+
" /center-arc-y\n"
|
873
|
+
" y top-of-words radius-y add add\n"
|
874
|
+
" def\n"
|
875
|
+
"\n"
|
876
|
+
" /Courier-Bold findfont labelfontsize scalefont setfont \n"
|
877
|
+
" center-arc-x center-arc-y string clear-word-box\n"
|
878
|
+
" center-arc-x center-arc-y string show-string-centered\n"
|
879
|
+
" } forall\n"
|
880
|
+
" end\n"
|
881
|
+
" } def\n"
|
882
|
+
"\n"
|
883
|
+
"/diagramdict 20 dict def\n"
|
884
|
+
"\n"
|
885
|
+
"/diagram\n"
|
886
|
+
"{diagramdict begin\n"
|
887
|
+
" /break-words exch def\n"
|
888
|
+
" /links exch def\n"
|
889
|
+
" /words exch def\n"
|
890
|
+
" /n words length def\n"
|
891
|
+
" /n-rows break-words length def\n"
|
892
|
+
" /Times-Roman findfont wordfontsize scalefont setfont\n"
|
893
|
+
"\n"
|
894
|
+
" /left-ends [0 dup words {stringwidth pop add gap add dup}\n"
|
895
|
+
" forall pop pop] def\n"
|
896
|
+
" /right-ends [0 words {stringwidth pop add dup gap add} forall pop] def\n"
|
897
|
+
"\n"
|
898
|
+
" /lwindows [ break-words {left-ends exch get gap 2 div sub } forall ] def\n"
|
899
|
+
" /rwindows [1 1 n-rows 1 sub {/i exch def\n"
|
900
|
+
" lwindows i get } for\n"
|
901
|
+
" right-ends n 1 sub get gap 2 div add\n"
|
902
|
+
" ] def\n"
|
903
|
+
"\n"
|
904
|
+
"\n"
|
905
|
+
" /max 0 def\n"
|
906
|
+
" 0 1 links length 1 sub {\n"
|
907
|
+
" /i exch def\n"
|
908
|
+
" /t links i get 2 get def\n"
|
909
|
+
" t max gt {/max t def} if\n"
|
910
|
+
" } for\n"
|
911
|
+
"\n"
|
912
|
+
" /max-height ed max mul ey add top-of-words add row-spacing add def\n"
|
913
|
+
" /total-height n-rows max-height mul row-spacing sub def\n"
|
914
|
+
"\n"
|
915
|
+
" /max-width 0 def % compute the widest window\n"
|
916
|
+
" 0 1 n-rows 1 sub {\n"
|
917
|
+
" /i exch def\n"
|
918
|
+
" /t rwindows i get lwindows i get sub def\n"
|
919
|
+
" t max-width gt {/max-width t def} if\n"
|
920
|
+
" } for\n"
|
921
|
+
"\n"
|
922
|
+
" centerpage max-width 2 div sub 0 translate % centers it\n"
|
923
|
+
" % rightpage max-width sub 0 translate % right justified\n"
|
924
|
+
" % Delete both of these to make it left justified\n"
|
925
|
+
"\n"
|
926
|
+
" n-rows 1 sub -1 0\n"
|
927
|
+
" {/i exch def\n"
|
928
|
+
" gsave\n"
|
929
|
+
" newpath\n"
|
930
|
+
" %/centering centerpage rwindows i get lwindows i get sub 2 div sub def\n"
|
931
|
+
" % this line causes each row to be centered\n"
|
932
|
+
" /centering 0 def\n"
|
933
|
+
" % set centering to 0 to prevent centering of each row \n"
|
934
|
+
"\n"
|
935
|
+
" centering -100 moveto % -100 because some letters go below zero\n"
|
936
|
+
" centering max-height n-rows mul lineto\n"
|
937
|
+
" rwindows i get lwindows i get sub centering add\n"
|
938
|
+
" max-height n-rows mul lineto\n"
|
939
|
+
" rwindows i get lwindows i get sub centering add\n"
|
940
|
+
" -100 lineto\n"
|
941
|
+
" closepath\n"
|
942
|
+
" clip\n"
|
943
|
+
" lwindows i get neg n-rows i sub 1 sub max-height mul translate\n"
|
944
|
+
" centerpage centering 0 translate\n"
|
945
|
+
" words links diagram-sentence-circle\n"
|
946
|
+
" grestore\n"
|
947
|
+
" } for\n"
|
948
|
+
" end\n"
|
949
|
+
"} def \n"
|
950
|
+
"\n"
|
951
|
+
"/diagramx\n"
|
952
|
+
"{diagramdict begin\n"
|
953
|
+
" /break-words exch def\n"
|
954
|
+
" /links exch def\n"
|
955
|
+
" /words exch def\n"
|
956
|
+
" /n words length def\n"
|
957
|
+
" /n-rows break-words length def\n"
|
958
|
+
" /Times-Roman findfont xwordfontsize scalefont setfont\n"
|
959
|
+
"\n"
|
960
|
+
" /left-ends [0 dup words {stringwidth pop add gap add dup}\n"
|
961
|
+
" forall pop pop] def\n"
|
962
|
+
" /right-ends [0 words {stringwidth pop add dup gap add} forall pop] def\n"
|
963
|
+
"\n"
|
964
|
+
" /lwindows [ break-words {left-ends exch get gap 2 div sub } forall ] def\n"
|
965
|
+
" /rwindows [1 1 n-rows 1 sub {/i exch def\n"
|
966
|
+
" lwindows i get } for\n"
|
967
|
+
" right-ends n 1 sub get xgap 2 div add\n"
|
968
|
+
" ] def\n"
|
969
|
+
"\n"
|
970
|
+
"\n"
|
971
|
+
" /max 0 def\n"
|
972
|
+
" 0 1 links length 1 sub {\n"
|
973
|
+
" /i exch def\n"
|
974
|
+
" /t links i get 2 get def\n"
|
975
|
+
" t max gt {/max t def} if\n"
|
976
|
+
" } for\n"
|
977
|
+
"\n"
|
978
|
+
" /max-height xed max mul xey add top-of-words add xrow-spacing add def\n"
|
979
|
+
" /total-height n-rows max-height mul xrow-spacing sub def\n"
|
980
|
+
"\n"
|
981
|
+
" /max-width 0 def % compute the widest window\n"
|
982
|
+
" 0 1 n-rows 1 sub {\n"
|
983
|
+
" /i exch def\n"
|
984
|
+
" /t rwindows i get lwindows i get sub def\n"
|
985
|
+
" t max-width gt {/max-width t def} if\n"
|
986
|
+
" } for\n"
|
987
|
+
"\n"
|
988
|
+
" centerpage max-width 2 div sub 0 translate % centers it\n"
|
989
|
+
" % rightpage max-width sub 0 translate % right justified\n"
|
990
|
+
" % Delete both of these to make it left justified\n"
|
991
|
+
"\n"
|
992
|
+
" n-rows 1 sub -1 0\n"
|
993
|
+
" {/i exch def\n"
|
994
|
+
" gsave\n"
|
995
|
+
" newpath\n"
|
996
|
+
" %/centering centerpage rwindows i get lwindows i get sub 2 div sub def\n"
|
997
|
+
" % this line causes each row to be centered\n"
|
998
|
+
" /centering 0 def\n"
|
999
|
+
" % set centering to 0 to prevent centering of each row \n"
|
1000
|
+
"\n"
|
1001
|
+
" centering -100 moveto % -100 because some letters go below zero\n"
|
1002
|
+
" centering max-height n-rows mul lineto\n"
|
1003
|
+
" rwindows i get lwindows i get sub centering add\n"
|
1004
|
+
" max-height n-rows mul lineto\n"
|
1005
|
+
" rwindows i get lwindows i get sub centering add\n"
|
1006
|
+
" -100 lineto\n"
|
1007
|
+
" closepath\n"
|
1008
|
+
" clip\n"
|
1009
|
+
" lwindows i get neg n-rows i sub 1 sub max-height mul translate\n"
|
1010
|
+
" centerpage centering 0 translate\n"
|
1011
|
+
" words links diagram-sentence-circle\n"
|
1012
|
+
" grestore\n"
|
1013
|
+
" } for\n"
|
1014
|
+
" end\n"
|
1015
|
+
"} def \n"
|
1016
|
+
"\n"
|
1017
|
+
"/ldiagram\n"
|
1018
|
+
"{diagramdict begin\n"
|
1019
|
+
" /break-words exch def\n"
|
1020
|
+
" /links exch def\n"
|
1021
|
+
" /words exch def\n"
|
1022
|
+
" /n words length def\n"
|
1023
|
+
" /n-rows break-words length def\n"
|
1024
|
+
" /Times-Roman findfont wordfontsize scalefont setfont\n"
|
1025
|
+
"\n"
|
1026
|
+
" /left-ends [0 dup words {stringwidth pop add gap add dup}\n"
|
1027
|
+
" forall pop pop] def\n"
|
1028
|
+
" /right-ends [0 words {stringwidth pop add dup gap add} forall pop] def\n"
|
1029
|
+
"\n"
|
1030
|
+
" /lwindows [ break-words {left-ends exch get gap 2 div sub } forall ] def\n"
|
1031
|
+
" /rwindows [1 1 n-rows 1 sub {/i exch def\n"
|
1032
|
+
" lwindows i get } for\n"
|
1033
|
+
" right-ends n 1 sub get gap 2 div add\n"
|
1034
|
+
" ] def\n"
|
1035
|
+
"\n"
|
1036
|
+
"\n"
|
1037
|
+
" /max 0 def\n"
|
1038
|
+
" 0 1 links length 1 sub {\n"
|
1039
|
+
" /i exch def\n"
|
1040
|
+
" /t links i get 2 get def\n"
|
1041
|
+
" t max gt {/max t def} if\n"
|
1042
|
+
" } for\n"
|
1043
|
+
"\n"
|
1044
|
+
" /max-height ed max mul ey add top-of-words add row-spacing add def\n"
|
1045
|
+
" /total-height n-rows max-height mul row-spacing sub def\n"
|
1046
|
+
"\n"
|
1047
|
+
" /max-width 0 def % compute the widest window\n"
|
1048
|
+
" 0 1 n-rows 1 sub {\n"
|
1049
|
+
" /i exch def\n"
|
1050
|
+
" /t rwindows i get lwindows i get sub def\n"
|
1051
|
+
" t max-width gt {/max-width t def} if\n"
|
1052
|
+
" } for\n"
|
1053
|
+
"\n"
|
1054
|
+
" % centerpage max-width 2 div sub 0 translate % centers it\n"
|
1055
|
+
" % rightpage max-width sub 0 translate % right justified\n"
|
1056
|
+
" % Delete both of these to make it left justified\n"
|
1057
|
+
"\n"
|
1058
|
+
" n-rows 1 sub -1 0\n"
|
1059
|
+
" {/i exch def\n"
|
1060
|
+
" gsave\n"
|
1061
|
+
" newpath\n"
|
1062
|
+
" %/centering centerpage rwindows i get lwindows i get sub 2 div sub def\n"
|
1063
|
+
" % this line causes each row to be centered\n"
|
1064
|
+
" /centering 0 def\n"
|
1065
|
+
" % set centering to 0 to prevent centering of each row \n"
|
1066
|
+
"\n"
|
1067
|
+
" centering -100 moveto % -100 because some letters go below zero\n"
|
1068
|
+
" centering max-height n-rows mul lineto\n"
|
1069
|
+
" rwindows i get lwindows i get sub centering add\n"
|
1070
|
+
" max-height n-rows mul lineto\n"
|
1071
|
+
" rwindows i get lwindows i get sub centering add\n"
|
1072
|
+
" -100 lineto\n"
|
1073
|
+
" closepath\n"
|
1074
|
+
" clip\n"
|
1075
|
+
" lwindows i get neg n-rows i sub 1 sub max-height mul translate\n"
|
1076
|
+
" centerpage centering 0 translate\n"
|
1077
|
+
" words links diagram-sentence-circle\n"
|
1078
|
+
" grestore\n"
|
1079
|
+
" } for\n"
|
1080
|
+
" end\n"
|
1081
|
+
"} def \n"
|
1082
|
+
;
|
1083
|
+
if (mode==1) return header_string;
|
1084
|
+
else return "";
|
1085
|
+
}
|