本文整理汇总了Java中edu.stanford.nlp.ling.Sentence.toWordList方法的典型用法代码示例。如果您正苦于以下问题:Java Sentence.toWordList方法的具体用法?Java Sentence.toWordList怎么用?Java Sentence.toWordList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.ling.Sentence
的用法示例。
在下文中一共展示了Sentence.toWordList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("usage: java TaggerDemo2 modelFile fileToTag");
return;
}
MaxentTagger tagger = new MaxentTagger(args[0]);
TokenizerFactory<CoreLabel> ptbTokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(),
"untokenizable=noneKeep");
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(args[1]), "utf-8"));
PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, "utf-8"));
DocumentPreprocessor documentPreprocessor = new DocumentPreprocessor(r);
documentPreprocessor.setTokenizerFactory(ptbTokenizerFactory);
for (List<HasWord> sentence : documentPreprocessor) {
List<TaggedWord> tSentence = tagger.tagSentence(sentence);
pw.println(Sentence.listToString(tSentence, false));
}
// print the adjectives in one more sentence. This shows how to get at words and tags in a tagged sentence.
List<HasWord> sent = Sentence.toWordList("The", "slimy", "slug", "crawled", "over", "the", "long", ",", "green", "grass", ".");
List<TaggedWord> taggedSent = tagger.tagSentence(sent);
for (TaggedWord tw : taggedSent) {
if (tw.tag().startsWith("JJ")) {
pw.println(tw.word());
}
}
pw.close();
}
示例2: batchTag
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
public List<TaggedWord> batchTag(List<String> sentence) {
String[] sen = new String[sentence.size()];
for (int i = 0; i < sentence.size(); i++)
sen[i] = sentence.get(i).replace(" ", "_");
List newSent = Sentence.toWordList(sen);
List taggedSentence = this.tagger.tagSentence(newSent);
List<TaggedWord> taggedSen = new ArrayList<>();
for (int i = 0; i < taggedSentence.size(); i++) {
TaggedWord tw = (TaggedWord)taggedSentence.get(i);
tw.setWord(sentence.get(i));
taggedSen.add(tw);
}
return taggedSen;
}
示例3: tag
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
public List<TaggedWord> tag(String sentence)
{
List<HasWord> tokens = Sentence.toWordList(sentence.split("\\s+"));
return tag(tokens);
}
示例4: defaultTestSentence
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
/**
* Return a default sentence for the language (for testing)
*/
public List<? extends HasWord> defaultTestSentence() {
String[] sent = {"Solch", "einen", "Zuspruch", "hat", "Angela", "Merkel", "lange", "nicht", "mehr", "erlebt", "."};
return Sentence.toWordList(sent);
}
示例5: defaultTestSentence
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
/**
* Return a default sentence for the language (for testing).
* The example is in UTF-8.
*/
public List<? extends HasWord> defaultTestSentence() {
String[] sent = {"هو","استنكر","الحكومة","يوم","امس","."};
return Sentence.toWordList(sent);
}
示例6: defaultTestSentence
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
public List<HasWord> defaultTestSentence() {
String[] sent = {"Ceci", "est", "seulement", "un", "test", "."};
return Sentence.toWordList(sent);
}
示例7: defaultTestSentence
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
public List<? extends HasWord> defaultTestSentence() {
String[] sent = {"H", "MWX", "MTPLC", "LA", "RQ", "M", "H", "TWPEH", "H", "MBIFH", "ALA", "GM", "M", "DRKI", "H", "HERMH", "yyDOT"};
return Sentence.toWordList(sent);
}
示例8: defaultTestSentence
import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
/** Returns the first sentence of TueBaDZ. */
public List<? extends HasWord> defaultTestSentence() {
return Sentence.toWordList("Veruntreute", "die", "AWO", "Spendengeld", "?");
}