Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.Word$WordFactoryHolder


          }

          // looks up tag name in list of known block-level tags
          String tagName = ws.substring(tagStartIndex, tagEndIndex + 1).toLowerCase();
          if (blockTags.contains(tagName)) {
            out.add(new Word("\n")); // mark newline for block-level tags
            justInsertedNewline = true;
          }
        }
      } else {
        out.add(w); // normal word
View Full Code Here


        basicDep.add(new TypedDependency(reln, new IndexedWord(gov.headWordNode().label()), new IndexedWord(dep.headWordNode().label())));
      }
    }

    // add the root
    TreeGraphNode dependencyRoot = new TreeGraphNode(new Word("ROOT"));
    dependencyRoot.setIndex(0);
    TreeGraphNode rootDep = root().headWordNode();
    if (rootDep == null) {
      List<Tree> leaves = Trees.leaves(root());
      if (leaves.size() > 0) {
View Full Code Here

    // parent child relationship between words and their POS tags.
    //
    // e.g. (ROOT (PRP I) (VBD hit) (DT the) (NN ball) (. .))

    TreeGraphNode root =
      new TreeGraphNode(new Word("ROOT-" + (tgPOSNodes.size() + 1)));
    root.setChildren(tgPOSNodes.toArray(new TreeGraphNode[tgPOSNodes.size()]));

    // Build list of TypedDependencies
    List<TypedDependency> tdeps = new ArrayList<TypedDependency>(tgWords.size());
View Full Code Here

    Matcher m = pat.matcher(inputDate);
    String str = m.replaceAll(" - ");
    str = str.replaceAll(",", " ");
    PTBTokenizer<Word> tokenizer = PTBTokenizer.newPTBTokenizer(new BufferedReader(new StringReader(str)));
    while (tokenizer.hasNext()) {
      Word nextToken = tokenizer.next();
      tokens.add(nextToken.toString());
    }
    if(DEBUG) {
      System.out.println("tokens:" + tokens);
    }
  }
View Full Code Here

  public static String tokensToString(Word [] tokens) {
    StringBuilder  sb = new StringBuilder(512);
    for(int i = 0; i < tokens.length; i ++){
      if(i > 0) sb.append(" ");
      Word l = tokens[i];
      sb.append(l.word() + "{" + l.beginPosition() + ", " + l.endPosition() + "}");
    }
    return sb.toString();
  }
View Full Code Here

  public Word [] tokenizeToWords() {
    List<WordToken> toks = tokenizeToWordTokens();
    Word [] labels = new Word[toks.size()];
    for(int i = 0; i < toks.size(); i ++){
      WordToken tok = toks.get(i);
      Word l = new Word(tok.getWord(), tok.getStart(), tok.getEnd());
      labels[i] = l;
    }
    return labels;
  }
View Full Code Here

   
    if(cachedPosition >= cachedTokens.length){
      return null;
    }
   
    Word token = cachedTokens[cachedPosition];
    cachedPosition ++;
   
    return token;
  }
View Full Code Here

  }

  private static ArrayList<Word> wordify(List wList) {
    ArrayList<Word> s = new ArrayList<Word>();
    for (Object obj : wList) {
      s.add(new Word(obj.toString()));
    }
    return s;
  }
View Full Code Here

  }

  private static ArrayList<Word> addLast(ArrayList<? extends Word> s) {
    ArrayList<Word> s2 = new ArrayList<Word>(s);
    //s2.add(new StringLabel(Lexicon.BOUNDARY));
    s2.add(new Word(Lexicon.BOUNDARY));
    return s2;
  }
View Full Code Here

   * the parse tree associated with that list.
   */
  public Tree parseStrings(List<String> lst) {
    List<Word> words = new ArrayList<Word>();
    for (String word : lst) {
      words.add(new Word(word));
    }
    return parse(words);
  }
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.ling.Word$WordFactoryHolder

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.