本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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
// }
// }
}
}
示例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);
}
示例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 {
}
}
示例11: toWordTag
import edu.stanford.nlp.ling.TaggedWord; //导入方法依赖的package包/类
private static WordTag toWordTag(TaggedWord tw) {
return new WordTag(tw.word(), tw.tag());
}