Пример #1
0
  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>();
  }
Пример #2
0
 public void setMaxParseSeconds(int maxParseSeconds) {
   if (!_is_inited) init();
   parser.getConfig().setMaxParseSeconds(maxParseSeconds);
 }
Пример #3
0
 public void setAllowSkippedWords(boolean allow) {
   if (!_is_inited) init();
   parser.getConfig().setAllowSkippedWords(allow);
 }
Пример #4
0
 public void setMaxCost(int maxCost) {
   if (!_is_inited) init();
   parser.getConfig().setMaxCost(maxCost);
 }
Пример #5
0
 /**
  * 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);
 }