本文整理汇总了Java中net.sf.extjwnl.data.POS.ADJECTIVE属性的典型用法代码示例。如果您正苦于以下问题:Java POS.ADJECTIVE属性的具体用法?Java POS.ADJECTIVE怎么用?Java POS.ADJECTIVE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.sf.extjwnl.data.POS
的用法示例。
在下文中一共展示了POS.ADJECTIVE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDerivedAdjective
/**
* Returns the derived adjective with the same word form for the most common
* sense of the given noun if exists.
*
* @param noun
* the noun
*/
public String getDerivedAdjective(String noun) {
try {
IndexWord nounIW = dict.lookupIndexWord(POS.NOUN, noun);
List<Synset> senses = nounIW.getSenses();
Synset mainSense = senses.get(0);
List<Pointer> pointers = mainSense.getPointers(PointerType.DERIVATION);
for (Pointer pointer : pointers) {
Synset derivedSynset = pointer.getTargetSynset();
if (derivedSynset.getPOS() == POS.ADJECTIVE) {
// return derivedSynset.getWords().get(0).getLemma();
}
if (derivedSynset.getPOS() == POS.VERB) {
System.out.println(derivedSynset);
}
}
} catch (JWNLException e) {
e.printStackTrace();
}
return null;
}
示例2: toPos
/**
* Convert a string (Penntree bank / simple word) to a Part of speech type.
*
* @param pos
* the pos
* @return the pos
*/
public static POS toPos(String pos) {
final String lc = pos.toLowerCase();
POS ret = null;
if (lc.startsWith("n")) {
ret = POS.NOUN;
} else if (lc.startsWith("v")) {
ret = POS.VERB;
} else if (lc.startsWith("r") || lc.startsWith("adv")) {
ret = POS.ADVERB;
} else if (lc.startsWith("j") || lc.startsWith("adj")) {
ret = POS.ADJECTIVE;
}
return ret;
}
示例3: 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;
}
}
示例4: getPos
private static POS getPos(String pos) {
pos = pos.toUpperCase();
if (PosUtils.isNoun(pos)) {
return POS.NOUN;
} else if (PosUtils.isVerb(pos)) {
return POS.VERB;
} else if (PosUtils.isAdjective(pos)) {
return POS.ADJECTIVE;
} else if (PosUtils.isAdverb(pos)) {
return POS.ADVERB;
} else {
return null;
}
}
示例5: toPos
public static POS toPos(String pos) {
String lc = pos.toLowerCase();
if (lc.startsWith("n")) {
return POS.NOUN;
} else if (lc.startsWith("v")) {
return POS.VERB;
} else if (lc.startsWith("r")) {
return POS.ADVERB;
} else if (lc.startsWith("j")) {
return POS.ADJECTIVE;
} else {
return null;
}
}
示例6: 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;
}
示例7: getRepresentative
public String getRepresentative(String w, String pos) {
POS posw;
if (pos.equals("NN") || pos.equals("NNS") || pos.equals("NNP") || pos.equals("NNPS")) {
posw = POS.NOUN;
} else if (pos.equals("VBZ") || pos.equals("VBG") || pos.equals("VBP") || pos.equals("VBN") || pos.equals("VBD") || pos.equals("VB")) {
posw = POS.VERB;
} else if (pos.equals("JJ")) {
posw = POS.ADJECTIVE;
} else {
if (pos.startsWith("V") || pos.startsWith("N")) {
System.out.println("POS discarded: " + pos);
}
return "";
}
if (!representative.containsKey(w)) {
IndexWord iw1 = null;
try {
iw1 = dictionary.getIndexWord(posw, w);
} catch (Exception e) {
}
String r = null;
if (iw1 != null) {
long[] offsets = iw1.getSynsetOffsets();
if (offsets.length > 0) {
//try only the first meaning
try {
Synset synset = dictionary.getSynsetAt(posw, offsets[0]);
for (Word word : synset.getWords()) {
String lemma = word.getLemma();
if (representative.containsKey(lemma)) {
r = lemma;
break;
}
}
} catch (JWNLException ex) {
Logger.getLogger(RepresentativeProvider.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
if (r != null) {
representative.put(w, representative.get(r));
} else {
representative.put(w, w);
}
newEntries++;
}
if (newEntries == UPDATE_FREQUENCY) {
saveRepresentatives();
newEntries = 0;
}
return representative.get(w);
}
示例8: getRandomPOS
/**
* Selects a random part of speech from the set based on the frequency of
* which they appear in the Wordnet dictionary
*
* @param set
* - a set of POS to choose from
* @return the chosen part of speech from set
*/
private static POS getRandomPOS(List<POS> set) {
POS result;
double totalFreq = 0.0;
double pNoun, pVerb, pAdjective, pAdverb;
for (POS pos : set) {
switch (pos) {
case NOUN:
totalFreq += NOUN;
break;
case VERB:
totalFreq += VERB;
break;
case ADJECTIVE:
totalFreq += ADJECTIVE;
break;
case ADVERB:
totalFreq += ADVERB;
break;
default:
break;
}
}
pNoun = NOUN / totalFreq;
pVerb = VERB / totalFreq;
pAdjective = ADJECTIVE / totalFreq;
pAdverb = ADVERB / totalFreq;
// Randomly select a valid POS
double rand = Math.random();
if (rand < pNoun) {
result = POS.NOUN;
} else if (rand < pNoun + pVerb) {
result = POS.VERB;
} else if (rand < pNoun + pVerb + pAdjective) {
result = POS.ADJECTIVE;
} else if (rand <= pNoun + pVerb + pAdjective + pAdverb) {
result = POS.ADVERB;
} else { // undefined
return null;
}
return result;
}