本文整理汇总了Java中edu.stanford.nlp.ling.WordTag类的典型用法代码示例。如果您正苦于以下问题:Java WordTag类的具体用法?Java WordTag怎么用?Java WordTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WordTag类属于edu.stanford.nlp.ling包,在下文中一共展示了WordTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
@Override
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
for (Token t : select(aJCas, Token.class)) {
//This corresponds roughly to what is happening in MorphaAnnotator.
String token = t.getCoveredText();
String lemma;
if (t.getPos() != null) {
lemma = morphology.lemmatize(new WordTag(token, t.getPos().getPosValue()))
.lemma();
}
else {
lemma = morphology.stem(token);
}
if (lemma == null) {
lemma = token;
}
Lemma l = new Lemma(aJCas, t.getBegin(), t.getEnd());
l.setValue(lemma);
l.addToIndexes();
t.setLemma(l);
}
}
开发者ID:tudarmstadt-lt,项目名称:sentiment,代码行数:25,代码来源:StanfordLemmatizer.java
示例2: makeObjects
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
@Override
protected
Set<?> makeObjects(Tree tree) {
List<TaggedWord> twList;
if (useTag) {
twList = myExtractor(tree);
} else {
twList = tree.taggedYield();
}
Set<Pair<Integer,WordTag>> set = new HashSet<Pair<Integer,WordTag>>();
for (int i = 0, sz = twList.size(); i < sz; i++) {
TaggedWord tw = twList.get(i);
//IntTaggedWord iTW = new IntTaggedWord(Numberer.number("words",tw.word()), Numberer.number("tags",tw.tag()));
Pair<Integer,WordTag> positionWT = new Pair<Integer,WordTag>(Integer.valueOf(i), new WordTag(tw.value(), tw.tag()));
//WordTag positionWT = new WordTag(tw.value(),tw.tag());
//System.out.println(iTW);
//if (! tw.tag.equals("*"))
set.add(positionWT);
}
if (DEBUG_MORE) System.err.println("Tags: " + set);
return set;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:23,代码来源:TaggingEval.java
示例3: lemmatizeText
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
public List<WordTag> lemmatizeText(String tokenizedText)
{
final List<WordTag> lemmatized = new ArrayList<WordTag>();
final String[] tokens = tokenizedText.split("\\s+");
for (String token : tokens)
{
final String lemma = analyzer.stem(token);
lemmatized.add(new WordTag(token, lemma));
}
return lemmatized;
}
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:14,代码来源:StanfordLemmatizer.java
示例4: apply
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
public Object apply(Object in) {
if (in instanceof WordTag) {
return stem((WordTag) in);
}
if (in instanceof Word) {
return stem((Word) in);
}
return in;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:Morphology.java
示例5: lemmatize
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
/**
* Lemmatize returning a <code>WordLemmaTag </code>.
*/
public WordLemmaTag lemmatize(WordTag wT) {
String tag = wT.tag();
String word = wT.word();
String lemma = stem(wT).word();
return new WordLemmaTag(word, lemma, tag);
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:Morphology.java
示例6: main
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
/** Run the morphological analyzer. Options are:
* <ul>
* <li>-rebuildVerbTable verbTableFile Convert a verb table from a text file
* (e.g., /u/nlp/data/morph/verbstem.list) to Java code contained in Morpha.flex .
* <li>-stem args ... Stem each of the following arguments, which should either be
* in the form of just word or word/tag.
* <li> args ... Each argument is a file and the contents of it are stemmed as
* space-separated tokens. <i>Note:</i> If the tokens are tagged
* words, they must be in the format of whitespace separated word_tag pairs.
*/
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.err.println("java Morphology [-rebuildVerbTable file|-stem word+|file+]");
} else if (args.length == 2 && args[0].equals("-rebuildVerbTable")) {
String verbs = IOUtils.slurpFile(args[1]);
String[] words = verbs.split("\\s+");
System.out.print(" private static String[] verbStems = new String[] { ");
for (int i = 0; i < words.length; i++) {
System.out.print("\"" + words[i] + "\"");
if (i != words.length - 1) {
System.out.print(", ");
if (i % 5 == 0) {
System.out.println();
System.out.print(" ");
}
}
}
System.out.println(" };");
} else if (args[0].equals("-stem")) {
for (int i = 1; i < args.length; i++) {
System.out.println(args[i] + " --> " + stemStatic(WordTag.valueOf(args[i])));
}
} else {
for (String arg : args) {
Morphology morph = new Morphology(arg);
for (Word next; (next = morph.next()) != null; ) {
System.out.print(next);
System.out.print(" ");
}
}
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:43,代码来源:Morphology.java
示例7: treeAsStemmedCollocation
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
private static String treeAsStemmedCollocation(Tree t, boolean threadSafe) {
List<WordTag> list= getStemmedWordTagsFromTree(t, threadSafe);
// err.println(list.size());
StringBuffer s = new StringBuffer(160);
WordTag firstWord = list.remove(0);
s.append(firstWord.word());
for(WordTag wt : list) {
s.append("_");
s.append(wt.word());
}
//err.println("Expressing this as:"+s.toString());
return s.toString();
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:14,代码来源:CollocationFinder.java
示例8: treeAsNonStemmedCollocation
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
private static String treeAsNonStemmedCollocation(Tree t) {
List<WordTag> list= getNonStemmedWordTagsFromTree(t);
StringBuffer s = new StringBuffer(160);
WordTag firstWord = list.remove(0);
s.append(firstWord.word());
for(WordTag wt : list) {
s.append("_");
s.append(wt.word());
}
return s.toString();
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:13,代码来源:CollocationFinder.java
示例9: getStemmedWordTagsFromTree
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
/**
*
* @param t a tree
* @return the WordTags corresponding to the leaves of the tree,
* stemmed according to their POS tags in the tree.
*/
private static List<WordTag> getStemmedWordTagsFromTree(Tree t, boolean threadSafe) {
List<WordTag> stemmedWordTags = Generics.newArrayList();
Sentence<TaggedWord> s = t.taggedYield();
for (TaggedWord w : s) {
WordTag wt = threadSafe ? Morphology.stemStaticSynchronized(w.word(), w.tag())
: Morphology.stemStatic(w.word(), w.tag());
stemmedWordTags.add(wt);
}
return stemmedWordTags;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:17,代码来源:CollocationFinder.java
示例10: getNonStemmedWordTagsFromTree
import edu.stanford.nlp.ling.WordTag; //导入依赖的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
示例11: processTree
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
private void processTree(Tree t, String tag) {
if (t.isPreTerminal()) {
tag = t.label().value();
}
if (t.isLeaf()) {
WordTag wt = morpha.stem(t.label().value(), tag);
t.label().setValue(wt.word());
} else {
for (Tree kid : t.children()) {
processTree(kid, tag);
}
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:14,代码来源:WordStemmer.java
示例12: getStemmedWordTagsFromTree
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
/**
*
* @param t a tree
* @return the WordTags corresponding to the leaves of the tree,
* stemmed according to their POS tags in the tree.
*/
private static List<WordTag> getStemmedWordTagsFromTree(Tree t, boolean threadSafe) {
List<WordTag> stemmedWordTags = Generics.newArrayList();
ArrayList<TaggedWord> s = t.taggedYield();
for (TaggedWord w : s) {
WordTag wt = threadSafe ? Morphology.stemStaticSynchronized(w.word(), w.tag())
: Morphology.stemStatic(w.word(), w.tag());
stemmedWordTags.add(wt);
}
return stemmedWordTags;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:17,代码来源:CollocationFinder.java
示例13: getNonStemmedWordTagsFromTree
import edu.stanford.nlp.ling.WordTag; //导入依赖的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
示例14: apply
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
public Object apply(Object in) {
if (in instanceof WordTag) {
WordTag wt = (WordTag) in;
String tag = wt.tag();
return new WordTag(lemmatize(wt.word(), tag, lexer, lexer.option(1)), tag);
}
if (in instanceof Word) {
return stem((Word) in);
}
return in;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:12,代码来源:Morphology.java
示例15: lemmatize
import edu.stanford.nlp.ling.WordTag; //导入依赖的package包/类
/**
* Lemmatize returning a <code>WordLemmaTag </code>.
*/
public WordLemmaTag lemmatize(WordTag wT) {
String tag = wT.tag();
String word = wT.word();
String lemma = lemma(word, tag);
return new WordLemmaTag(word, lemma, tag);
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:10,代码来源:Morphology.java
注:本文中的edu.stanford.nlp.ling.WordTag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论