Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.Label


        if(span.first < start) start = span.first;
        if(span.second > end) end = span.second;
      }
    }

    Label label = label();
    if (label instanceof CoreMap) {
    CoreMap afl = (CoreMap) label();
      afl.set(CoreAnnotations.BeginIndexAnnotation.class, start);
      afl.set(CoreAnnotations.EndIndexAnnotation.class, end);
    }
View Full Code Here


  protected class ArabicSubcategoryStripper implements TreeTransformer {

    protected final TreeFactory tf = new LabeledScoredTreeFactory();

    public Tree transformTree(Tree tree) {
      Label lab = tree.label();
      String s = lab.value();

      if (tree.isLeaf()) {
        Tree leaf = tf.newLeaf(lab);
        leaf.setScore(tree.score());
        return leaf;
View Full Code Here

    if (useGT) {
      unknownGTTrainer.train(tw, weight);
    }

    String word = tw.word();
    Label tagL = new Tag(tw.tag());
    String first = word.substring(0, 1);
    if (useUnicodeType) {
      char ch = word.charAt(0);
      int type = Character.getType(ch);
      if (type != Character.OTHER_LETTER) {
View Full Code Here

    private static final long serialVersionUID = 8914098359495987617L;

    /** Doesn't accept nodes that only cover an empty. */
    public boolean test(Tree t) {
      Tree[] kids = t.children();
      Label l = t.label();
      // Delete (return false for) empty/trace nodes (ones marked '-NONE-')
      return ! ((l != null) && "-NONE-".equals(l.value()) && !t.isLeaf() && kids.length == 1 && kids[0].isLeaf());
    }
View Full Code Here

    if (t == null || t.isLeaf()) {
      return t;
    }

    List<String> annotations = new ArrayList<String>();
    Label lab = t.label();
    String word = null;
    if (lab instanceof HasWord) {
      word = ((HasWord) lab).word();
    }
    String tag = null;
    if (lab instanceof HasTag) {
      tag = ((HasTag) lab).tag();
    }
    String cat = lab.value();
    // Tree parent = t.parent(root);

    if (t.isPhrasal()) {

      List<String> childBasicCats = childBasicCats(t);
View Full Code Here

    return getNext(txt, originalText, null);
  }

  private Object getNext(String txt, String originalText, String annotation) {
    txt = removeSoftHyphens(txt);
    Label w = (Label) tokenFactory.makeToken(txt, yychar, yylength());
    if (invertible || annotation != null) {
      CoreLabel word = (CoreLabel) w;
      if (invertible) {
        String str = prevWordAfter.toString();
        prevWordAfter.setLength(0);
View Full Code Here

  public Tree transformTree(Tree tree) {
    if (tree.isPreTerminal() || tree.isLeaf()) {
      return tree.deepCopy();
    }

    Label label = tree.label().labelFactory().newLabel(tree.label());
    Tree[] children = tree.children();
    while (children.length == 1 && !children[0].isLeaf()) {
      children = children[0].children();
    }
    List<Tree> processedChildren = Generics.newArrayList();
View Full Code Here

    for (Tree child : tree.children()) {
      setSentimentLabels(child);
    }

    Label label = tree.label();
    if (!(label instanceof CoreLabel)) {
      throw new IllegalArgumentException("Required a tree with CoreLabels");
    }
    CoreLabel cl = (CoreLabel) label;
    cl.setValue(Integer.toString(RNNCoreAnnotations.getPredictedClass(tree)));
View Full Code Here

    if (DEBUG) {
      System.err.println("Span "+start+" to "+end+" word "+wordIndex.get(words[hWord])+"/"+hWord+" tag "+tagIndex.get(hTag)+"/"+hTag+" score "+iScore(start, end, hWord, hTag));
    }
    String headWordStr = wordIndex.get(words[hWord]);
    String headTagStr = tagIndex.get(hTag);
    Label headLabel = new CategoryWordTag(headWordStr, headWordStr, headTagStr);
    int numTags = tagIndex.size();

    // deal with span 1
    if (end - start == 1) {
      Tree leaf = tf.newLeaf(new Word(headWordStr));
View Full Code Here

    if (children.isEmpty()) return;
    //TODO: fix determineHead
    // - in phrases like "World Trade Organization 's" the head of the parent NP is "POS".
    // - this is problematic for the collocationFinder which assigns this head
    // as the POS for the collocation "World_Trade_Organization"!
    Label headLabel= hf.determineHead(t).label();
    StringBuffer testString = null;
    Integer leftSistersBuffer=0;//measures the length of sisters in words when reading
    for (int i = 0; i < children.size();i++){
      ArrayList<Integer> childConstituents = new ArrayList<Integer>();
      childConstituents.add(i);
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.ling.Label

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.