Package edu.stanford.nlp.trees

Examples of edu.stanford.nlp.trees.HeadFinder


  public static void main(String[] args) {
    // simple testing code
    Treebank treebank = new DiskTreebank();
    CategoryWordTag.suppressTerminalDetails = true;
    treebank.loadPath(args[0]);
    final HeadFinder chf = new NoPunctuationHeadFinder();
    treebank.apply(pt -> {
      pt.percolateHeads(chf);
      pt.pennPrint();
      System.out.println();
    });
View Full Code Here


    transformer.addTransformer(binarizer);
    transformer.addTransformer(basicTransformer);

    treebank = treebank.transform(transformer);

    HeadFinder binaryHeadFinder = new BinaryHeadFinder(op.tlpParams.headFinder());
    List<Tree> binarizedTrees = Generics.newArrayList();
    for (Tree tree : treebank) {
      Trees.convertToCoreLabels(tree);
      tree.percolateHeadAnnotations(binaryHeadFinder);
      // Index from 1.  Tools downstream expect index from 1, so for
View Full Code Here

   */
  @Override
  public int setOptionFlag(String[] args, int i) {
    if (args[i].equalsIgnoreCase("-headFinder") && (i + 1 < args.length)) {
      try {
        HeadFinder hf = (HeadFinder) Class.forName(args[i + 1]).newInstance();
        setHeadFinder(hf);

        optionsString.append("HeadFinder: " + args[i + 1] + "\n");
      } catch (Exception e) {
        System.err.println(e);
View Full Code Here

      if (t2.isLeaf()) {
        return false;
      } else if (t2.isPreTerminal()) {
        return (t2.firstChild() == t1);
      } else {
        HeadFinder headFinder = matcher.getHeadFinder();
        if (headFinder == null) headFinder = this.hf;
        Tree head = headFinder.determineHead(t2);
        if (head == t1) {
          return true;
        } else {
          return satisfies(t1, head, root, matcher);
        }
View Full Code Here

          advance();
        }

        @Override
        public void advance() {
          HeadFinder headFinder = matcher.getHeadFinder();
          if (headFinder == null) headFinder = hf;

          Tree last = next;
          next = matcher.getParent(next);
          if (next != null && headFinder.determineHead(next) != last) {
            next = null;
          }
        }
      };
    }
View Full Code Here

      return new SearchNodeIterator() {
        @Override
        void initialize() {
          if (t != matcher.getRoot()) {
            next = matcher.getParent(t);
            HeadFinder headFinder = matcher.getHeadFinder() == null ? hf : matcher.getHeadFinder();
            if (headFinder.determineHead(next) != t) {
              next = null;
            }
          }
        }
      };
View Full Code Here

    int fontSize = Preferences.getFontSize();
    if(fontSize != 0)
      DisplayMatchesPanel.getInstance().setFontSize(Preferences.getFontSize());

    //advanced stuff
    HeadFinder hf = Preferences.getHeadFinder();
    InputPanel.getInstance().setHeadFinder(hf);

    TreeReaderFactory trf = Preferences.getTreeReaderFactory();
    FilePanel.getInstance().setTreeReaderFactory(trf);

    String hfName = hf.getClass().getSimpleName();
    String trfName = trf.getClass().getSimpleName();
    String encoding = Preferences.getEncoding();
    if(encoding != null && !encoding.equals(""))
      FileTreeModel.setCurEncoding(encoding);
    if (PreferencesPanel.isChinese(hfName, trfName))
View Full Code Here

    } else if(headfinderName.equalsIgnoreCase("TueBaDZHeadFinder")) {
      return new TueBaDZHeadFinder();
    } else {//try to find the class
      try {
        Class<?> headfinder = Class.forName(headfinderName);
        HeadFinder hf = (HeadFinder) headfinder.newInstance();
        return hf;
      } catch (Exception e) {
        return null;
      }
    }
View Full Code Here

    }
  }

  Tree convertTree(String treeText) {
    Options op = new Options();
    HeadFinder binaryHeadFinder = new BinaryHeadFinder(op.tlpParams.headFinder());
    Tree tree = Tree.valueOf(treeText);
    Trees.convertToCoreLabels(tree);
    tree.percolateHeadAnnotations(binaryHeadFinder);
    return tree;
  }
View Full Code Here

      collinizerRetainsPunctuation = true;
      i++;

    } else if (args[i].equalsIgnoreCase("-headFinder") && (i + 1 < args.length)) {
      try {
        HeadFinder hf = (HeadFinder) Class.forName(args[i + 1]).newInstance();
        setHeadFinder(hf);
        optionsString.append("HeadFinder: " + args[i + 1] + "\n");

      } catch (Exception e) {
        System.err.println(e);
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.trees.HeadFinder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.