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


Java JWNLException.printStackTrace方法代码示例

本文整理汇总了Java中net.didion.jwnl.JWNLException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java JWNLException.printStackTrace方法的具体用法?Java JWNLException.printStackTrace怎么用?Java JWNLException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.didion.jwnl.JWNLException的用法示例。


在下文中一共展示了JWNLException.printStackTrace方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetWordSenses

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * Pulls a noun "tank" from the dictionary and checks to see if it has 5 senses.
 *
 */
public void testGetWordSenses() {
    try {
        JWNL.initialize(TestDefaults.getInputStream());
        IndexWord word = Dictionary.getInstance().getIndexWord(POS.NOUN, "tank");
  
        assertTrue(word.getSenseCount() == 5); 
        
        word = Dictionary.getInstance().getIndexWord(POS.VERB, "eat");
        assertTrue(word.getSenseCount() == 6); 
        
        word = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, "quick");
        assertTrue(word.getSenseCount() == 6); 
        
        word = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, "big");
        assertTrue(word.getSenseCount() == 13); 
        
    } catch(JWNLException e) {
        fail("Exception in testGetSenses caught");
        e.printStackTrace();
    } 
}
 
开发者ID:duguyue100,项目名称:chomsky,代码行数:26,代码来源:Wordnet30SynsetTest.java

示例2: canBePersonOrSystem

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public static boolean canBePersonOrSystem(String fullNoun, String mainNoun) {
	try {
		if(Constants.f_personCorrectorList.contains(fullNoun)) {
			return true;
		}
		if(ProcessingUtils.isPersonalPronoun(mainNoun)) {
			return true;
		}
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, fullNoun);
		if(_idw == null || (!_idw.getLemma().contains(mainNoun)))
			_idw = f_dictionary.lookupIndexWord(POS.NOUN, mainNoun);
		return checkHypernymTree(_idw,Constants.f_realActorDeterminers);	
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:18,代码来源:WordNetWrapper.java

示例3: isInteractionVerb

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public static boolean isInteractionVerb(Action a) {
	String _verb = getBaseForm(a.getName());
	if(Constants.f_interactionVerbs.contains(_verb)) {
		return true;
	}
	if(!isWeakVerb(_verb)) {
		try {		
			IndexWord _idw = null;
			if(a.getMod() != null && ((a.getModPos()-a.getWordIndex())<2)) {
				_idw = f_dictionary.lookupIndexWord(POS.VERB, _verb+" "+a.getMod());
			}
			if(_idw == null) {
				_idw = f_dictionary.lookupIndexWord(POS.VERB, _verb+" "+a.getPrt());
			}
			if(_idw == null) {
				_idw = f_dictionary.lookupIndexWord(POS.VERB, _verb);
			}
			if(_idw != null) {
				return checkHypernymTree(_idw,Constants.f_interactionVerbs);
			}
		} catch (JWNLException e) {
			e.printStackTrace();
		}
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:27,代码来源:WordNetWrapper.java

示例4: getBaseForm

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * tries to lookup the word in wordnet and if found
 * return the lemma (base form) of the verb.
 * if it is not found, the verb is returned unchanged.
 * @param verb
 * @return
 */
public static String getBaseForm(String verb,boolean keepAuxiliaries,POS pos) {
	String[] _parts = verb.split(" "); //verb can contain auxiliary verbs (to acquire)
	try {
           IndexWord word = f_dictionary.lookupIndexWord(pos,_parts[_parts.length-1]);
           if (word != null) {
           	_parts[_parts.length-1] = word.getLemma();
           	StringBuilder _b = new StringBuilder();
           	for(int i=keepAuxiliaries?0:_parts.length-1;i<_parts.length;i++) {
           		String _s = _parts[i];
           		_b.append(_s);
           		_b.append(' ');
           	}
           	_b.deleteCharAt(_b.length()-1);
           	return _b.toString(); 
           }      
       } catch (JWNLException e) {
       	e.printStackTrace();
       }
       return verb;
   }
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:28,代码来源:WordNetWrapper.java

示例5: lemmatize

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:opennlp-addons,代码行数:41,代码来源:JWNLLemmatizer.java

示例6: isAnimate

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public static boolean isAnimate(String noun) {
	try {			
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, noun);
		return checkHypernymTree(_idw,ListUtils.getList("animate_thing"));	
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:WordNetWrapper.java

示例7: canBeGroupAction

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public static boolean canBeGroupAction(String mainNoun) {
	try {			
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, mainNoun);
		return checkHypernymTree(_idw,ListUtils.getList("group_action"));	
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:WordNetWrapper.java

示例8: isTimePeriod

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public static boolean isTimePeriod(String mainNoun) {
	try {			
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, mainNoun);
		return checkHypernymTree(_idw,ListUtils.getList("time_period"));	
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:WordNetWrapper.java

示例9: deriveVerb

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public static String deriveVerb(String noun) {
	try {
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, noun);
		if(_idw == null) {
			System.err.println("Could not find IndexWord for: "+noun);
			return null;
		}
		String _selected = null;
		int _distance = 0;
		for(Synset s: _idw.getSenses()) {
			Pointer[] _targets = s.getPointers();
			for(Pointer p:_targets) {
				if(p.getType() == PointerType.NOMINALIZATION && p.getTargetPOS() == POS.VERB) {
					for(Word w:p.getTargetSynset().getWords()) {
						int _d = StringUtils.calculateEditDistance(w.getLemma(), noun);
						if(_selected == null || _d<_distance) {
							_selected = w.getLemma();
							_distance = _d;
						}
					}						
				}
			}
		}
		return _selected;
	} catch (JWNLException e) {
		e.printStackTrace();
		return null;
	}	
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:30,代码来源:WordNetWrapper.java

示例10: isMetaActor

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * @param lowerCase
 * @return
 */
public static boolean isMetaActor(String fullNoun,String noun) {
	if(!Constants.f_personCorrectorList.contains(fullNoun)) {
		try {
			IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, fullNoun);
			if(_idw == null || (!_idw.getLemma().contains(noun)))
				_idw = f_dictionary.lookupIndexWord(POS.NOUN, noun);
			return checkHypernymTree(_idw,Constants.f_metaActorsDeterminers);	
		} catch (JWNLException e) {
			e.printStackTrace();
		}
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:18,代码来源:WordNetWrapper.java

示例11: isVerbOfType

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * compares the given verb and all synonyms/hypernyms with the type word
 * this way it can be checked if, e.g., a verb is of type "end" or "finish".
 * @param verb
 * @param type
 * @return
 */
public static boolean isVerbOfType(String verb, String type) {
	try {
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.VERB, verb);
		return checkHypernymTree(_idw,ListUtils.getList(type));	
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:17,代码来源:WordNetWrapper.java

示例12: canBeDataObject

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * @param name
 * @return
 */
public static boolean canBeDataObject(String fullNoun,String noun) {
	try {
		IndexWord _idw = f_dictionary.lookupIndexWord(POS.NOUN, fullNoun);
		if(_idw == null || (!_idw.getLemma().contains(noun)))
			_idw = f_dictionary.lookupIndexWord(POS.NOUN, noun);
		return checkHypernymTree(_idw,Constants.f_dataObjectDeterminers);	
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:16,代码来源:WordNetWrapper.java

示例13: getSenseKey

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
/**
 * Gets the sense key of a lemma. This will be refactored in 2.0 with 
 * the architecture reworking. 
 * @param lemma lemma sense to grab
 * @return sense key for lemma
 */
public String getSenseKey(String lemma) {
	int ss_type = 5;
	if (this.getPOS().equals(POS.NOUN)) {
		ss_type = 1;
	} else if (this.getPOS().equals(POS.VERB)) {
		ss_type = 2;
	} else if (this.getPOS().equals(POS.ADJECTIVE)) {
		ss_type = 3;
	} else if (this.getPOS().equals(POS.ADVERB)) {
		ss_type = 4;
	}
		
	if (isAdjectiveCluster()) {
		ss_type = 5;
	}
	int lexId = -1;
	for (int i = 0; i < this.getWords().length; i++) {
		Word w = this.getWords()[i];
		if (w.getLemma().equals(lemma)) {
			lexId = w.getLexId();
		}
	}
	
	String lexNumStr = "";
	long lexNum = getLexFileNum();
	if (lexNum < 10) {
		lexNumStr = "0" + lexNum;
	} else {
		lexNumStr = String.valueOf(lexNum);
	}
	
	String lexIdStr = "";
	if (lexId < 10) {
		lexIdStr = "0" + lexId;
	} else {
		lexIdStr = String.valueOf(lexId);
	}

	String senseKey = lemma + "%" + ss_type + ":" + lexNumStr;
	senseKey += ":" + lexIdStr + ":";
	
	String head = ":";
	if (ss_type == 5) {
		try {
			Pointer[] p = this.getPointers(PointerType.SIMILAR_TO);
			if (p.length > 0) {
				Pointer headWord = p[0];
				Word[] words = headWord.getTargetSynset().getWords();
				if (words.length > 0) {
					head = words[0].getLemma() + ":";
					lexIdStr = "";
					if (words[0].getLexId() < 10) {
						lexIdStr = "0" + words[0].getLexId();
					} else {
						lexIdStr = String.valueOf(words[0].getLexId());
					}
					head += lexIdStr;
				}
			}
		} catch (JWNLException e) { 
			e.printStackTrace(); 
		}
	}
	senseKey += head;
	
	return senseKey;
	
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:75,代码来源:Synset.java

示例14: testMorphological

import net.didion.jwnl.JWNLException; //导入方法依赖的package包/类
public void testMorphological() {
	try {  
		JWNL.initialize(TestDefaults.getInputStream());
		IndexWord iw = Dictionary.getInstance().lookupIndexWord(POS.VERB, "running-away");
         
		System.out.println("Index word : " + iw.toString());
		
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	
	
}
 
开发者ID:duguyue100,项目名称:chomsky,代码行数:14,代码来源:ExamplesTest.java


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