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


Java Sentence.toWordList方法代码示例

本文整理汇总了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();
}
 
开发者ID:tudarmstadt-lt,项目名称:sentiment,代码行数:29,代码来源:TaggerDemo2.java

示例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;
}
 
开发者ID:mojtaba-khallash,项目名称:JHazm,代码行数:16,代码来源:POSTagger.java

示例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);
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:6,代码来源:StanfordPOSTagger.java

示例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);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:8,代码来源:NegraPennTreebankParserParams.java

示例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);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:9,代码来源:ArabicTreebankParserParams.java

示例6: defaultTestSentence

import edu.stanford.nlp.ling.Sentence; //导入方法依赖的package包/类
public List<HasWord> defaultTestSentence() {
  String[] sent = {"Ceci", "est", "seulement", "un", "test", "."};
  return Sentence.toWordList(sent);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:5,代码来源:FrenchTreebankParserParams.java

示例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);
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:5,代码来源:HebrewTreebankParserParams.java

示例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", "?");
}
 
开发者ID:amark-india,项目名称:eventspotter,代码行数:5,代码来源:TueBaDZParserParams.java


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