Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.WordTag


  public void testPairsHolder() {
    PairsHolder pairsHolder = new PairsHolder();

    for (int i = 0; i < 10; i++) {
      pairsHolder.add(new WordTag("girl", "NN"));
    }

    MaxentTagger maxentTagger = new MaxentTagger();
    maxentTagger.init(null);
View Full Code Here


  public PairsHolder() {}

  public void setSize(int s) {
    while (arr.size() < s) {
      arr.add(new WordTag(null,"NN"))// todo: remove NN.  NA okay?
    }
  }
View Full Code Here

          wordRes = wordRes.replaceAll("\u0961", " ");
        } catch (Exception e) {
          System.err.println("stem: Didn't work");
        }
      }
      return new WordTag(wordRes, tag);
    } catch (Throwable e) {
      System.err.println("Morphology.stem() had error on word " + word + "/" +
                         tag);
      if (DEBUG) e.printStackTrace();
      return new WordTag(word, tag);
    }
  }
View Full Code Here

      // iterate over the words in the sentence
      for (int i = 0; i < yield.length() + 1; i++) {
        History h = new History(numWords+numSentences, numWords+numSentences + yield.length(), numWords+numSentences + i, pairs);
        String tag = tags.get(i);
        String word = words.get(i);
        pairs.add(new WordTag(word,tag));
        int y = GlobalHolder.tags.add(tag);
        DataWordTag dat = new DataWordTag(h, y);
        v.add(dat);
        GlobalHolder.dict.add(word, tag);
View Full Code Here

      // iterate over the words in the sentence
      for (int i = 0; i < endPos + 1; i++) {
        History h = new History(prevPos, prevPos + endPos, prevPos + i, pairs);
        String tag = tags.get(i);
        String word = words.get(i);
        pairs.add(new WordTag(word,tag));
        int y = GlobalHolder.tags.add(tag);
        DataWordTag dat = new DataWordTag(h, y);
        v.add(dat);
        GlobalHolder.dict.add(word, tag);
      }
View Full Code Here

  private void processTree(Tree t, String tag) {
    if (t.isPreTerminal()) {
      tag = t.label().value();
    }
    if (t.isLeaf()) {
      WordTag wt = morpha.stem(t.label().value(), tag);
      t.label().setValue(wt.word());
    } else {
      for (Tree kid : t.children()) {
        processTree(kid, tag);
      }
    }
View Full Code Here

  private static String treeAsStemmedCollocation(Tree t, boolean threadSafe) {
    List<WordTag> list= getStemmedWordTagsFromTree(t, threadSafe);
    // err.println(list.size());
    StringBuffer s = new StringBuffer(160);
    WordTag firstWord = list.remove(0);
    s.append(firstWord.word());
    for(WordTag wt : list) {
      s.append("_");
      s.append(wt.word());
    }
    //err.println("Expressing this as:"+s.toString());
View Full Code Here

  private static String treeAsNonStemmedCollocation(Tree t) {
    List<WordTag> list= getNonStemmedWordTagsFromTree(t);

    StringBuffer s = new StringBuffer(160);
    WordTag firstWord = list.remove(0);
    s.append(firstWord.word());
    for(WordTag wt : list) {
      s.append("_");
      s.append(wt.word());
    }
    return s.toString();
View Full Code Here

   */
  private static List<WordTag> getStemmedWordTagsFromTree(Tree t, boolean threadSafe) {
    List<WordTag> stemmedWordTags = Generics.newArrayList();
    Sentence<TaggedWord> s = t.taggedYield();
    for (TaggedWord w : s) {
      WordTag wt = threadSafe ? Morphology.stemStaticSynchronized(w.word(), w.tag())
              : Morphology.stemStatic(w.word(), w.tag());
      stemmedWordTags.add(wt);
    }
    return stemmedWordTags;
  }
View Full Code Here

  private static List<WordTag> getNonStemmedWordTagsFromTree(Tree t) {
    List<WordTag> wordTags = Generics.newArrayList();
    Sentence<TaggedWord> s = t.taggedYield();
    for (TaggedWord w : s) {
      WordTag wt = new WordTag(w.word(), w.tag());
      wordTags.add(wt);
    }
    return wordTags;
  }
View Full Code Here

TOP

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

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.