本文整理汇总了Java中edu.mit.jwi.item.POS类的典型用法代码示例。如果您正苦于以下问题:Java POS类的具体用法?Java POS怎么用?Java POS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
POS类属于edu.mit.jwi.item包,在下文中一共展示了POS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJWIStylePos
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public static POS getJWIStylePos(String postag){
if (verb_postag.contains(postag)){
return POS.VERB;
}
else if (real_noun_postag.contains(postag)){
return POS.NOUN;
}
else if (adj_postag.contains(postag)){
return POS.ADJECTIVE;
}
else if (adv_postag.contains(postag)){
return POS.ADVERB;
}
else {
return POS.NOUN;
}
}
示例2: check
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public boolean check(Map<Variable, String> assignment)
{
final String sourceString = source == null ? sourceLiteral : assignment.get(source);
final String targetString = target == null ? targetLiteral : assignment.get(target);
String posString = source != null ? source.type : target.type;
POS pos = posString.equals("noun") ? POS.NOUN : POS.VERB;
// if we're checking a constraint where one of the variables hasn't been
// assigned yet, it passes for now
if (sourceString == null || targetString == null)
return true;
if (hypernym)
return wordNet.isHypernym(pos, sourceString, pos, targetString);
// hyponym otherwise, which is just the reverse
return wordNet.isHypernym(pos, targetString, pos, sourceString);
}
示例3: getSense
import edu.mit.jwi.item.POS; //导入依赖的package包/类
@Override
public String getSense(String lemma, TAG pos) {
String sense = null, word;
IIndexWord indexWord = null;
POS POS;
boolean multi;
int i = 0;
word = lemma;
multi = lemma.contains(MULTIWORD_SEPARATOR);
POS = getPOS(pos);
do {
word = lemma.replace(MULTIWORD_SEPARATOR, SEPARATORS[i++]);
indexWord = mDictionary.getIndexWord(word, POS);
if (indexWord != null)
sense = mDictionary.getWord(indexWord.getWordIDs().get(0)).getSenseKey().toString();
} while (sense == null && multi && i < SEPARATORS.length);
return sense;
}
示例4: main
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
BabelMorph bm = BabelMorph.getInstance();
System.out.println(bm.getBabelMorphVersion());
//retrieve all the available languages
Set<Language> languages = bm.getBabelMorphLanguages();
System.out.println("available languages:\n"+languages.toString());
//retrieve all the available part-of-speech
Set<POS> pos = bm.getBabelMorphPoS();
System.out.println("available parts-of-speech:\n"+pos.toString());
System.out.println("word stats:");
countAllWordsByPOS(bm);
System.out.println("lemma stats:");
countAllLemmasByPOS(bm);
}
示例5: getPOSFromPenn
import edu.mit.jwi.item.POS; //导入依赖的package包/类
/**
* JWI POS tag from Penn tag. (by Nils Reiter)
*
* @param postag
* @return
*/
public static POS getPOSFromPenn(String postag) {
POS pos = null;
switch (postag.charAt(0)) {
case 'J':
case 'j':
pos = POS.ADJECTIVE;
break;
case 'N':
case 'n':
pos = POS.NOUN;
break;
case 'V':
case 'v':
pos = POS.VERB;
break;
case 'R':
case 'r':
if (postag.charAt(1) == 'B' || postag.charAt(1) == 'b')
pos = POS.ADVERB;
break;
}
return pos;
}
示例6: convertArk
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public static POS convertArk(String arkTag) {
if (arkTag.equals("N") || arkTag.equals("O") || arkTag.equals("^")
|| arkTag.equals("S") || arkTag.equals("Z")) {
return POS.NOUN;
}
if (arkTag.equals("V")) {
return POS.VERB;
}
if (arkTag.equals("A")) {
return POS.ADJECTIVE;
}
if (arkTag.equals("R")) {
return POS.ADVERB;
}
return null;
}
示例7: getWordnetPOS
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public static POS getWordnetPOS(CoreLabel word){
String stanfordPOS = word.getString(PartOfSpeechAnnotation.class);
if(stanfordPOS.startsWith("N"))
return POS.NOUN;
if(stanfordPOS.startsWith("J"))
return POS.ADJECTIVE;
if(stanfordPOS.startsWith("V"))
return POS.VERB;
if(stanfordPOS.startsWith("R"))
return POS.ADVERB;
return null;
}
示例8: getMeaning
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public String getMeaning(int nType, int order){
POS pos;
switch(nType){
case nNOUN:
pos = POS.NOUN;
break;
case nVERB:
pos = POS.VERB;
break;
case nADJ:
pos = POS.ADJECTIVE;
break;
case nADV:
pos = POS.ADVERB;
break;
default:
pos = POS.NOUN;
break;
}
String gloss = dict.getSynset(
dict.getIndexWord(wordName, pos).getWordIDs().get(order).getSynsetID()).getGloss();
int partitionIndex = gloss.indexOf('\"');
return gloss.substring(0, (partitionIndex < 0) ? gloss.length() : partitionIndex);
}
示例9: main
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public static void main(String[] args) {
WordnetRulesSource wns = new WordnetRulesSource();
StringBuilder bs = new StringBuilder();
IIndexWord iw1 = wns.dictionary().getIndexWord("person", POS.NOUN);
runWord(wns, iw1, bs);
iw1 = wns.dictionary().getIndexWord("adult", POS.NOUN);
runWord(wns, iw1, bs);
iw1 = wns.dictionary().getIndexWord("human", POS.NOUN);
runWord(wns, iw1, bs);
iw1 = wns.dictionary().getIndexWord("profession", POS.NOUN);
runWord(wns, iw1, bs);
FileTools.saveString("/home/milen/jobs.txt", bs.toString(), true);
wns.close();
}
示例10: getAllGlosses
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public String getAllGlosses(String search_word) {
int i = 1;
for (POS p : POS_ARR) {
IIndexWord idxWord = dict.getIndexWord(search_word, p);
if (idxWord == null)
continue;
List<IWordID> wordIDs = idxWord.getWordIDs();
for (IWordID wordID : wordIDs) {
IWord iword = dict.getWord(wordID);
m.append(String.format(Locale.getDefault(), "%d. (%s) %s\n",
i, shorten(iword.getPOS().toString()), iword.getSynset()
.getGloss()));
++i;
}
}
return m.toString();
}
示例11: getTopGlosses
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public String getTopGlosses(String search_word) {
int i = 1;
for (POS p : POS_ARR) {
IIndexWord idxWord = dict.getIndexWord(search_word, p);
if (idxWord == null)
continue;
List<IWordID> wordIDs = idxWord.getWordIDs();
IWordID wordID = wordIDs.get(0);
IWord iword = dict.getWord(wordID);
m.append(String.format(Locale.getDefault(), "%d. (%s) %s\n",
i, shorten(iword.getPOS().toString()), iword.getSynset()
.getGloss()));
++i;
}
return m.toString();
}
示例12: loadExceptions
import edu.mit.jwi.item.POS; //导入依赖的package包/类
static void loadExceptions(POS type, String name) {
try {
InputStream is = Lemmatizer.class.getResourceAsStream(name + ".exc");
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
Map<String, String> map = new HashMap<String, String>();
exceptions.put(type, map);
while ((line = br.readLine()) != null)
{
String[] split = line.split(" ");
map.put(new String(split[0]), new String(split[1]));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例13: getSynsetType
import edu.mit.jwi.item.POS; //导入依赖的package包/类
private static POS getSynsetType(String pos) {
if (!synsetTypeForPOS.containsKey(pos)) {
POS result = null;
if (pos.startsWith("NN")) {
result = POS.NOUN;
} else if (pos.startsWith("VB")) {
result = POS.VERB;
} else if (pos.startsWith("RB")) {
result = POS.ADVERB;
} else if (pos.startsWith("JJ")) {
result = POS.ADJECTIVE;
}
if (result != null) {
synsetTypeForPOS.put(pos, result);
}
}
return synsetTypeForPOS.get(pos);
}
示例14: getAll
import edu.mit.jwi.item.POS; //导入依赖的package包/类
public static List<WordParse> getAll(String wordString, POS pos) {
if (dict == null) {
return null;
}
IIndexWord idxWord = dict.getIndexWord(wordString, pos);
if (idxWord == null)
return null;
List<IWordID> words = idxWord.getWordIDs();
if (words == null)
return null;
List<WordParse> parsed = new ArrayList(words.size());
for (IWordID iw : words) {
IWordID wordID = idxWord.getWordIDs().get(0);
IWord word = dict.getWord(wordID);
parsed.add(new WordParse(wordString, word));
}
return parsed;
}
示例15: getWordOffsets
import edu.mit.jwi.item.POS; //导入依赖的package包/类
/**
* Obtains the list of offsets for all senses of an input term
* @param word
* @param tag
* @return
*/
public static List<String> getWordOffsets(String word, POS tag)
{
List<IWord> senses = WordNetUtils.getInstance().getSenses(word,tag);
List<String> wordOffsets = new ArrayList<String>();
for(IWord sense : senses)
{
int offset = sense.getSynset().getOffset();
String strOffset = fixOffset(offset,tag);
wordOffsets.add(strOffset);
}
return wordOffsets;
}