Examples of TaggedWord


Examples of edu.stanford.nlp.ling.TaggedWord

    for (List<TaggedWord> sentence : reader) {
      if (maxentTagger.wordFunction != null) {
        List<TaggedWord> newSentence =
          new ArrayList<TaggedWord>(sentence.size());
        for (TaggedWord word : sentence) {
          TaggedWord newWord =
            new TaggedWord(maxentTagger.wordFunction.apply(word.word()),
                           word.tag());
          newSentence.add(newWord);
        }
        sentence = newSentence;
      }
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

    if (tree.isPreTerminal()) {
      // fill in initial lexicon here
      String tag = tree.label().value();
      String word = tree.children()[0].label().value();
      TaggedWord tw = new TaggedWord(word, state(tag, 0));
      lex.train(tw, position, weight);
      return (position + 1);
    }

    if (tree.children().length == 2) {
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

      }
      double scale = 1.0 / (1.0 + LEX_SMOOTH);
      double smoothing = total * LEX_SMOOTH / stateWeights.length;
      for (int state = 0; state < stateWeights.length; ++state) {
        // TODO: maybe optimize all this TaggedWord creation
        TaggedWord tw = new TaggedWord(word, state(tag, state));
        tempLex.train(tw, position, (Math.exp(stateWeights[state]) + smoothing) * scale);
      }
      return position + 1;
    }

View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

      System.out.println("Uh-oh dates!");
    }

    System.out.println("Testing tagged word");
    ClassicCounter<TaggedWord> c = new ClassicCounter<TaggedWord>();
    TaggedWord tw1 = new TaggedWord("w", "t");
    c.incrementCount(tw1);
    TaggedWord tw2 = new TaggedWord("w", "t2");
    System.out.println(c.containsKey(tw2));
    System.out.println(tw1.equals(tw2));

    WordTag wt1 = toWordTag(tw1);
    WordTag wt2 = toWordTag(tw2);
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

  private static List<TaggedWord> cleanTags(List<TaggedWord> twList, TreebankLanguagePack tlp) {
    int sz = twList.size();
    List<TaggedWord> l = new ArrayList<TaggedWord>(sz);
    for (int i = 0; i < sz; i++) {
      TaggedWord tw = twList.get(i);
      TaggedWord tw2 = new TaggedWord(tw.word(), tlp.basicCategory(tw.tag()));
      l.add(tw2);
    }
    return l;
  }
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

    if (split <= 0) {    // == 0 isn't allowed - no empty words!
      return w;
    }
    String word = s.substring(0, split);
    String tag = s.substring(split + 1, s.length());
    return new TaggedWord(word, tag);
  }
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

  Sentence<TaggedWord> getTaggedSentence() {
    Sentence<TaggedWord> taggedSentence = new Sentence<TaggedWord>();
    for (int j = 0; j < size - 1; j++) {
      String tag = finalTags[j];
      TaggedWord w = new TaggedWord(sent.get(j), tag);
      taggedSentence.add(w);
    }
    return taggedSentence;
  }
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

    ArrayList<TaggedWord> taggedWords = new ArrayList<TaggedWord>();
    // leave out EOS
    for (int j = 0, len = size - 1; j < len; j++) {
      String tag = finalTags[j];
      TaggedWord w = new TaggedWord(sent.get(j), tag);
      taggedWords.add(w);
    }

    return new Sentence<TaggedWord>(taggedWords);
  }
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

      if (node.isLeaf() || node.children().length < 2) {
        continue;
      }
      // every child with a different head (or repeated) is an argument
      Label l = node.label();
      TaggedWord tw = null;
      if (l instanceof HasWord && l instanceof HasTag) {
        tw = new TaggedWord(((HasWord) l).word(), ((HasTag) l).tag());
      }

      boolean seenHead = false;
      for (Tree child : node.children()) {
        Label dl = child.label();
        TaggedWord dtw = null;
        if (dl instanceof HasWord && dl instanceof HasTag) {
          dtw = new TaggedWord(((HasWord) dl).word(), ((HasTag) dl).tag());
        }
        if (tw != null && tw.word() != null && dtw != null && tw.word().equals(dtw.word()) && tw.tag().equals(dtw.tag()) && !seenHead) {
          seenHead = true;
        } else {
          Dependency<Label, Label, Object> p = new UnnamedDependency(tw, dtw);
          if (f.accept(p)) {
            deps.add(p);
View Full Code Here

Examples of edu.stanford.nlp.ling.TaggedWord

      if (node.isLeaf() || node.children().length < 2) {
        continue;
      }
      // every child with a different head (or repeated) is an argument
      Label l = node.label();
      TaggedWord w = null;
      if (hf != null) {
        Tree hwt = node.headPreTerminal(hf);
        if (hwt != null) {
          w = new TaggedWord(hwt.children()[0].label(), hwt.label());
        }
      } else {
        if (l instanceof HasWord && l instanceof HasTag) {
          w = new TaggedWord(((HasWord) l).word(), ((HasTag) l).tag());
        }
      }

      boolean seenHead = false;
      for (Tree child : node.children()) {
        Label dl = child.label();
        TaggedWord dw = null;
        if (hf != null) {
          Tree dwt = child.headPreTerminal(hf);
          if (dwt != null) {
            dw = new TaggedWord(dwt.children()[0].label(), dwt.label());
          }
        } else {
          if (dl instanceof HasWord && dl instanceof HasTag) {
            dw = new TaggedWord(((HasWord) dl).word(), ((HasTag) dl).tag());
          }
        }
        // System.out.println("XX Doing pair: " + l + ", " + dl +
        //                 " gives " + w + ", " +dw);
        if (w != null && w.word() != null && w.tag() != null && dw != null && w.word().equals(dw.word()) && w.tag().equals(dw.tag()) && !seenHead) {
          seenHead = true;
        } else {
          Dependency<Label, Label, Object> p = new UnnamedDependency(w, dw);
          if (f.accept(p)) {
            deps.add(p);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.