当前位置: 首页>>代码示例>>Java>>正文


Java TaggedWord.word方法代码示例

本文整理汇总了Java中edu.stanford.nlp.ling.TaggedWord.word方法的典型用法代码示例。如果您正苦于以下问题:Java TaggedWord.word方法的具体用法?Java TaggedWord.word怎么用?Java TaggedWord.word使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.ling.TaggedWord的用法示例。


在下文中一共展示了TaggedWord.word方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rawParse

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
public ConcurrentDependencyGraph rawParse(List<TaggedWord> sentence)
        throws IOException,
        MaltChainedException {
    String[] conll = new String[sentence.size()];
    for (int i = 0; i < sentence.size(); i++) {
        TaggedWord taggedWord = sentence.get(i);
        String word = taggedWord.word();
        String Lemma = "_";
        if (this.lemmatizer != null)
            Lemma = this.lemmatizer.lemmatize(word);
        String pos = taggedWord.tag();

        conll[i] = String.format("%s\t%s\t%s\t%s\t%s\t%s",
                i + 1, word, Lemma, pos, pos, "_");
    }
    return parse(conll);
}
 
开发者ID:mojtaba-khallash,项目名称:JHazm,代码行数:18,代码来源:DependencyParser.java

示例2: train

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
/**
 * Trains this lexicon on the Collection of trees.
 */
public void train(TaggedWord tw, int loc, double weight) {
  IntTaggedWord iTW = 
    new IntTaggedWord(tw.word(), tw.tag(), wordIndex, tagIndex);
  IntTaggedWord iT = new IntTaggedWord(nullWord, iTW.tag);
  IntTaggedWord iW = new IntTaggedWord(iTW.word, nullTag);
  seenCounter.incrementCount(iW, weight);
  IntTaggedWord i = NULL_ITW;
    
  if (treesRead > indexToStartUnkCounting) {
    // start doing this once some way through trees; 
    // treesRead is 1 based counting
    if (seenCounter.getCount(iW) < 2) {
      // it's an entirely unknown word
      int s = model.getSignatureIndex(iTW.word, loc, 
                                      wordIndex.get(iTW.word));
      IntTaggedWord iTS = new IntTaggedWord(s, iTW.tag);
      IntTaggedWord iS = new IntTaggedWord(s, nullTag);
      unSeenCounter.incrementCount(iTS, weight);
      unSeenCounter.incrementCount(iT, weight);
      unSeenCounter.incrementCount(iS, weight);
      unSeenCounter.incrementCount(i, weight);
    }
  }
}
 
开发者ID:chbrown,项目名称:stanford-parser,代码行数:28,代码来源:FrenchUnknownWordModelTrainer.java

示例3: cleanTags

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
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;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:11,代码来源:FactoredParser.java

示例4: getNonStemmedWordTagsFromTree

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
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;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:CollocationFinder.java

示例5: listToEvents

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
protected List<IntTaggedWord> listToEvents(List<TaggedWord> taggedWords) {
  List<IntTaggedWord> itwList = new ArrayList<IntTaggedWord>();
  for (TaggedWord tw : taggedWords) {
    IntTaggedWord iTW = new IntTaggedWord(tw.word(), tw.tag(), wordIndex, tagIndex);
    itwList.add(iTW);
  }
  return itwList;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:9,代码来源:BaseLexicon.java

示例6: getNonStemmedWordTagsFromTree

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
private static List<WordTag> getNonStemmedWordTagsFromTree(Tree t) {
  List<WordTag> wordTags = Generics.newArrayList();
  ArrayList<TaggedWord> s = t.taggedYield();
  for (TaggedWord w : s) {
    WordTag wt = new WordTag(w.word(), w.tag());
    wordTags.add(wt);
  }
  return wordTags;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:10,代码来源:CollocationFinder.java

示例7: train

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
public void train(TaggedWord tw, int loc, double weight) {
  if (useGT) {
    unknownGTTrainer.train(tw, weight);
  }
  
  // scan data
  String word = tw.word();
  String subString = model.getSignature(word, loc);
        
  Label tag = new Tag(tw.tag());;
  if ( ! c.containsKey(tag)) {
    c.put(tag, new ClassicCounter<String>());
  }
  c.get(tag).incrementCount(subString, weight);
  
  tc.incrementCount(tag, weight);
  
  seenEnd.add(subString);
  
  String tagStr = tw.tag();
  IntTaggedWord iW = new IntTaggedWord(word, IntTaggedWord.ANY, wordIndex, tagIndex);
  seenCounter.incrementCount(iW, weight);
  if (treesRead > indexToStartUnkCounting) {
    // start doing this once some way through trees; 
    // treesRead is 1 based counting
    if (seenCounter.getCount(iW) < 2) {
      IntTaggedWord iT = new IntTaggedWord(IntTaggedWord.ANY, tagStr, wordIndex, tagIndex);
      unSeenCounter.incrementCount(iT, weight);
      unSeenCounter.incrementCount(NULL_ITW, weight);
    }
  }
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:33,代码来源:BaseUnknownWordModelTrainer.java

示例8: train

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
/**
 * Trains this UWM on the Collection of trees.
 */
public void train(TaggedWord tw, int loc, double weight) {
  IntTaggedWord iTW = 
    new IntTaggedWord(tw.word(), tw.tag(), wordIndex, tagIndex);
  IntTaggedWord iT = new IntTaggedWord(nullWord, iTW.tag);
  IntTaggedWord iW = new IntTaggedWord(iTW.word, nullTag);
  seenCounter.incrementCount(iW, weight);
  IntTaggedWord i = NULL_ITW;
  
  if (treesRead > indexToStartUnkCounting) {
    // start doing this once some way through trees; 
    // treesRead is 1 based counting
    if (seenCounter.getCount(iW) < 1.5) {
      // it's an entirely unknown word
      int s = model.getSignatureIndex(iTW.word, loc, 
                                      wordIndex.get(iTW.word));
      if (DOCUMENT_UNKNOWNS) {
        String wStr = wordIndex.get(iTW.word);
        String tStr = tagIndex.get(iTW.tag);
        String sStr = wordIndex.get(s);
        EncodingPrintWriter.err.println("Unknown word/tag/sig:\t" +
                                        wStr + '\t' + tStr + '\t' + 
                                        sStr, "UTF-8");
      }
      IntTaggedWord iTS = new IntTaggedWord(s, iTW.tag);
      IntTaggedWord iS = new IntTaggedWord(s, nullTag);
      unSeenCounter.incrementCount(iTS, weight);
      unSeenCounter.incrementCount(iT, weight);
      unSeenCounter.incrementCount(iS, weight);
      unSeenCounter.incrementCount(i, weight);
      // rules.add(iTS);
      // sigs.add(iS);
    } // else {
      // if (seenCounter.getCount(iTW) < 2) {
      // it's a new tag for a known word
      // do nothing for now
      // }
      // }
  }
}
 
开发者ID:chbrown,项目名称:stanford-parser,代码行数:43,代码来源:EnglishUnknownWordModelTrainer.java

示例9: train

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
public void train(TaggedWord tw, double weight) {
  tokens = tokens + weight;
  String word = tw.word();
  String tag = tw.tag();
        
  // TaggedWord has crummy equality conditions            
  Pair<String,String> wt = new Pair<String,String>(word, tag);
  wtCount.incrementCount(wt, weight);
        
  tagCount.incrementCount(tag, weight);
  seenWords.add(word);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:13,代码来源:UnknownGTTrainer.java

示例10: train

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
/**
 * Trains this lexicon on the Collection of trees.
 */
public void train(TaggedWord tw, int loc, double weight) {
  IntTaggedWord iTW = 
    new IntTaggedWord(tw.word(), tw.tag(), wordIndex, tagIndex);
  IntTaggedWord iT = new IntTaggedWord(nullWord, iTW.tag);
  IntTaggedWord iW = new IntTaggedWord(iTW.word, nullTag);
  seenCounter.incrementCount(iW, weight);
  IntTaggedWord i = NULL_ITW;
  
  if (treesRead > indexToStartUnkCounting) {
    // start doing this once some way through trees; 
    // treesRead is 1 based counting
    if (seenCounter.getCount(iW) < 2) {
      // it's an entirely unknown word
      int s = model.getSignatureIndex(iTW.word, loc, 
                                      wordIndex.get(iTW.word));
      if (DOCUMENT_UNKNOWNS) {
        String wStr = wordIndex.get(iTW.word);
        String tStr = tagIndex.get(iTW.tag);
        String sStr = wordIndex.get(s);
        EncodingPrintWriter.err.println("Unknown word/tag/sig:\t" +
                                        wStr + '\t' + tStr + '\t' + 
                                        sStr, "UTF-8");
      }
      IntTaggedWord iTS = new IntTaggedWord(s, iTW.tag);
      IntTaggedWord iS = new IntTaggedWord(s, nullTag);
      unSeenCounter.incrementCount(iTS, weight);
      unSeenCounter.incrementCount(iT, weight);
      unSeenCounter.incrementCount(iS, weight);
      unSeenCounter.incrementCount(i, weight);
    } // else {
  }
}
 
开发者ID:chbrown,项目名称:stanford-parser,代码行数:36,代码来源:ArabicUnknownWordModelTrainer.java

示例11: toWordTag

import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
private static WordTag toWordTag(TaggedWord tw) {
  return new WordTag(tw.word(), tw.tag());
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:4,代码来源:ChineseUnknownWordModel.java


注:本文中的edu.stanford.nlp.ling.TaggedWord.word方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。