本文整理汇总了Java中net.didion.jwnl.data.POS.NOUN属性的典型用法代码示例。如果您正苦于以下问题:Java POS.NOUN属性的具体用法?Java POS.NOUN怎么用?Java POS.NOUN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.didion.jwnl.data.POS
的用法示例。
在下文中一共展示了POS.NOUN属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: synonymsOf
/**
* @param token A token from the domain e.g. "v-kidnap"
* @return A list of synonyms (with "v-" attached)
*/
private List<String> synonymsOf(String token) {
POS pos = POS.VERB;
if( token.startsWith("n") ) pos = POS.NOUN;
String header = token.substring(0, 2);
// Get the synsets.
Synset[] synsets = _wordnet.synsetsOf(token.substring(2), pos);
// Get all words in all synsets.
List<String> synonyms = new ArrayList<String>();
if( synsets != null ) {
for( Synset synset : synsets ) {
List<String> syms = _wordnet.wordsInSynset(synset);
// System.out.println(" token " + token + " synset " + synset + ": " + syms);
for( String sym : syms ) {
String strtoken = header + sym;
if( !synonyms.contains(strtoken) )
synonyms.add(strtoken);
}
}
}
return synonyms;
}
示例2: getJwnlPartOfSpeec
static POS getJwnlPartOfSpeec(WordNetPartOfSpeech partOfSpeech)
{
switch(partOfSpeech)
{
case ADJECTIVE:
return POS.ADJECTIVE;
case ADVERB:
return POS.ADVERB;
case NOUN:
return POS.NOUN;
case VERB:
return POS.VERB;
default:
return null;
}
}
示例3: lemmatize
/**
* It takes a word and a POS tag and obtains a word's lemma from WordNet.
*
* @param word
* @param postag
* @return lemma
*/
public String lemmatize(String word, String postag) {
String constantTag = "NNP";
IndexWord baseForm;
String lemma = null;
try {
POS pos;
if (postag.startsWith("N") || postag.startsWith("n")) {
pos = POS.NOUN;
} else if (postag.startsWith("V") || postag.startsWith("v")) {
pos = POS.VERB;
} else if (postag.startsWith("J") || postag.startsWith("a")) {
pos = POS.ADJECTIVE;
} else if (postag.startsWith("RB") || postag.startsWith("r")) {
pos = POS.ADVERB;
} else {
pos = POS.ADVERB;
}
baseForm = morphy.lookupBaseForm(pos, word);
if (baseForm != null) {
lemma = baseForm.getLemma().toString();
}
else if (baseForm == null && postag.startsWith(String.valueOf(constantTag))) {
lemma = word;
}
else {
lemma= word.toLowerCase();
}
} catch (JWNLException e) {
e.printStackTrace();
return null;
}
return lemma;
}
示例4: getPOS
private POS getPOS(String pos) {
POS POSTag;
POSMap.TAG tag;
tag = POSMap.getInstance().getPOS(pos);
switch (tag) {
case n:
POSTag = POS.NOUN;
break;
case v:
POSTag = POS.VERB;
break;
case a:
POSTag = POS.ADJECTIVE;
break;
case r:
POSTag = POS.ADVERB;
break;
default:
POSTag = POS.NOUN;
break;
}
return POSTag;
}
示例5: getPOS
private POS getPOS(POSMap.TAG tag) {
POS POSTag;
switch (tag) {
case n:
POSTag = POS.NOUN;
break;
case v:
POSTag = POS.VERB;
break;
case a:
POSTag = POS.ADJECTIVE;
break;
case r:
POSTag = POS.ADVERB;
break;
default:
POSTag = POS.NOUN;
break;
}
return POSTag;
}
示例6: getLemmaForWord
public String getLemmaForWord(String word, String pos)
{
if(wordLemmaMap.containsKey(word+"_"+pos))
return wordLemmaMap.get(word+"_"+pos);
POS wnPOS=null;
if(pos.startsWith("V"))
{
wnPOS = POS.VERB;
}
else if(pos.startsWith("J"))
{
wnPOS = POS.ADJECTIVE;
}
else if(pos.startsWith("R"))
{
wnPOS = POS.ADVERB;
}
else
wnPOS = POS.NOUN;
if(word.equals("'ve"))
word="have";
else if(word.equals("n't"))
word="not";
else if(word.equals("'s")&&pos.startsWith("V"))
word="is";
else if(word.equals("'ll"))
word="will";
else if(word.equals("'re"))
word="are";
String lemma=getLemma(word, wnPOS);
wordLemmaMap.put(word+"_"+pos, lemma);
return lemma;
}
示例7: calculateContent
public void calculateContent(IDFMap idf, WordNet wordnet) {
_synsetCounts = new HashMap<Integer,Integer>();
int i = 0;
for( String word : idf.getWords() ) {
// Don't bother on rare words...
if( idf.getFrequency(word) > 0 ) {
if( i % 500 == 0 ) {
System.out.println(i + "/" + idf.getWords().size() + ":\t" + word);
Util.reportMemory();
}
Pair split = CalculateIDF.splitKey(word);
String token = (String)split.second();
char pos = (Character)split.first();
// Only do verbs and nouns.
// if( pos == 'v' || pos == 'n' ) {
POS type = POS.NOUN;
if( pos == 'v' ) type = POS.VERB;
else if( pos == 'j' ) type = POS.ADJECTIVE;
Set<Synset> ancestors = wordnet.getAllSynsetAncestors(token, type);
if( ancestors != null)
for( Synset synset : ancestors )
Util.incrementCount(_synsetCounts, synset.hashCode(), idf.getFrequency(word));
// }
}
// if( i == 3000 ) break;
i++;
}
Synset root = wordnet.getRootSynset();
System.out.println("root synset\t" + root);
_totalAtWordnetRoot = _synsetCounts.get(root.hashCode());
System.out.println("root total\t" + _totalAtWordnetRoot);
}
示例8: getCountAtSynset
public double getCountAtSynset(String key) {
Pair split = CalculateIDF.splitKey(key);
String token = (String)split.second();
char pos = (Character)split.first();
POS type = POS.NOUN;
if( pos == 'v' ) type = POS.VERB;
else if( pos == 'j' ) type = POS.ADJECTIVE;
return getCountAtSynset(token, type);
}
示例9: getICAtSynset
public double getICAtSynset(String key) {
Pair split = CalculateIDF.splitKey(key);
String token = (String)split.second();
char pos = (Character)split.first();
POS type = POS.NOUN;
if( pos == 'v' ) type = POS.VERB;
else if( pos == 'j' ) type = POS.ADJECTIVE;
return getICAtSynset(token, type);
}
示例10: getWordNetPartOfSpeech
static WordNetPartOfSpeech getWordNetPartOfSpeech(POS pos)
{
if (null==pos)
return null;
if (POS.ADJECTIVE == pos)
return WordNetPartOfSpeech.ADJECTIVE;
else if (POS.ADVERB == pos)
return WordNetPartOfSpeech.ADVERB;
else if (POS.NOUN == pos)
return WordNetPartOfSpeech.NOUN;
else if (POS.VERB == pos)
return WordNetPartOfSpeech.VERB;
return null;
}
示例11: int2POS
/** converts GATE pos to JWNL pos */
public static POS int2POS(int pos) {
POS result = null;
switch(pos) {
case WordNet.POS_ADJECTIVE:
result = POS.ADJECTIVE;
break;
case WordNet.POS_ADVERB:
result = POS.ADVERB;
break;
case WordNet.POS_NOUN:
result = POS.NOUN;
break;
case WordNet.POS_VERB:
result = POS.VERB;
break;
default:
throw new IllegalArgumentException();
}
return result;
}