/** * Parses a sentence, using the parser. The private ArrayList of currentParses is filled with the * ParsedSentences. */ private Sentence parseSentence(String sentence) { if (sentence == null) return null; Sentence sent = null; if (sentence.length() < DEFAULT_MAX_SENTENCE_LENGTH) { sent = parser.parse(sentence); } else { System.err.println("Sentence too long, len=" + sentence.length() + " : " + sentence); sent = new Sentence(); } return sent; }
private void init() { if (_is_inited) return; _is_inited = true; // At this time, we only have algs for English. // So, don't waste CPU time on algs if its not English. if (null != _lang && "en" != _lang) do_apply_algs = false; parser = _use_sock ? new RemoteLGParser() : new LocalLGParser(); if (null != _lang) parser.setLanguage(_lang); if (null != _dict_path) parser.setDictPath(_dict_path); parser.getConfig().setStoreConstituentString(true); parser.getConfig().setStoreSense(true); // XXX TODO: this is loading the English Language morphy; // we need to load a generic language handler. Morphy morphy = MorphyFactory.getImplementation(MorphyFactory.DEFAULT_SINGLE_THREAD_IMPLEMENTATION); context = new RelexContext(parser, morphy); sentenceAlgorithmApplier = new SentenceAlgorithmApplier(); setMaxParses(DEFAULT_MAX_PARSES); setMaxParseSeconds(DEFAULT_MAX_PARSE_SECONDS); setMaxCost(DEFAULT_MAX_PARSE_COST); // Hobbs-algo stuff. phraseMarkup = new PhraseMarkup(); antecedents = new Antecedents(); hobbs = new Hobbs(antecedents); doco = new Document(); stats = new ParseStats(); sumtime = new TreeMap<String, Long>(); cnttime = new TreeMap<String, Long>(); }
public void setMaxParseSeconds(int maxParseSeconds) { if (!_is_inited) init(); parser.getConfig().setMaxParseSeconds(maxParseSeconds); }
public void setAllowSkippedWords(boolean allow) { if (!_is_inited) init(); parser.getConfig().setAllowSkippedWords(allow); }
public void setMaxCost(int maxCost) { if (!_is_inited) init(); parser.getConfig().setMaxCost(maxCost); }
/** * Set the max number of parses that are computed. Default: 1000; default is set in * link-grammar/jni-client.c * * <p>Sets the max number of linkages (parses) that are computed by link-grammar. This should be * set to a value that is significantly larger than the expected number of parses for a sentence. * Setting this below 1000 is strongly discourged, you won't get what you want. Use setMaxParses() * above to control the number of parses displayed. * * <p>Caution: Setting this number too low will result in a **random** subset of possible linakges * to be explored. This random subset might not include the best (highest-scoring) linkages, which * is probably not what you want. This method is here really so as to increase the number of * linakges about 1000 (for the ANY language). */ public void setMaxLinkages(int maxLinkages) { if (!_is_inited) init(); parser.setMaxLinkages(maxLinkages); }
/** * Set the max number of parses. This will NOT reduce processing time; up to 1000 parses are still * computed, but only this many are returned. To reduce processing time, use setMaxLinkages below. */ public void setMaxParses(int maxParses) { if (!_is_inited) init(); parser.getConfig().setMaxLinkages(maxParses); }
public String getVersion() { if (!_is_inited) init(); return parser.getVersion() + "\t" + Version.getVersion(); }