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


Java POS类代码示例

本文整理汇总了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;
	}
}
 
开发者ID:cs-zyluo,项目名称:CausalNet,代码行数:19,代码来源:DepSet.java

示例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);
}
 
开发者ID:anadrome,项目名称:word-constraints,代码行数:17,代码来源:WordNetConstraint.java

示例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;
}
 
开发者ID:SI3P,项目名称:supWSD,代码行数:26,代码来源:WordNetInventory.java

示例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);
  
}
 
开发者ID:raganato,项目名称:BabelMorph,代码行数:19,代码来源:Stats.java

示例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;
}
 
开发者ID:annefried,项目名称:sitent,代码行数:30,代码来源:WordNetUtils.java

示例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;
}
 
开发者ID:millecker,项目名称:senti-storm,代码行数:17,代码来源:POSTag.java

示例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;
	
	
}
 
开发者ID:everling,项目名称:PRECISE,代码行数:18,代码来源:Parser.java

示例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);
}
 
开发者ID:MusicCraftor,项目名称:WordNet-Explorer,代码行数:25,代码来源:WordDic.java

示例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();
}
 
开发者ID:kouylekov,项目名称:edits,代码行数:20,代码来源:WordnetRulesSource.java

示例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();
	}
 
开发者ID:vin-ivar,项目名称:XDictionary,代码行数:19,代码来源:DictSearch.java

示例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();
	}
 
开发者ID:vin-ivar,项目名称:XDictionary,代码行数:18,代码来源:DictSearch.java

示例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);
    }
  }
 
开发者ID:mikelewis0,项目名称:easyccg,代码行数:19,代码来源:Lemmatizer.java

示例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);
}
 
开发者ID:mikelewis0,项目名称:easyccg,代码行数:22,代码来源:Lemmatizer.java

示例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;
    
}
 
开发者ID:automenta,项目名称:netentionj-desktop,代码行数:24,代码来源:WordParse.java

示例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;
}
 
开发者ID:pilehvar,项目名称:ADW,代码行数:22,代码来源:GeneralUtils.java


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