本文整理汇总了Java中net.didion.jwnl.data.Word类的典型用法代码示例。如果您正苦于以下问题:Java Word类的具体用法?Java Word怎么用?Java Word使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Word类属于net.didion.jwnl.data包,在下文中一共展示了Word类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInteger
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* Assumes the given token is a noun.
* @return true if the token has a synset with an ancestor that is Integer
*/
public boolean isInteger(String token) {
Synset[] synsets = synsetsOf(token, POS.NOUN);
// System.out.println("isNounEntity top " + token);
if( synsets == null ) {
// System.out.println("isNounEntity null synsets: " + token);
}
else {
for( Synset synset : synsets ) {
List<Synset> chain = hypernymChainKeepChild(synset);
if( chain != null ) {
for( Synset parent : chain ) {
// System.out.println(parent);
Word[] words = parent.getWords();
if( (words.length > 0 && words[0].getLemma().equals("integer")) )
return true;
}
}
}
}
return false;
}
示例2: isMaterial
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* Assumes the given token is a noun.
* WordNet does not put material (explosive, rocks, dust, fiber, etc.) under "physical objects".
* @return true if the token has a synset with an ancestor that is a "material" synset.
*
*/
public boolean isMaterial(String token) {
if( _isMaterial == null ) _isMaterial = new HashMap<String, Boolean>();
if( _isMaterial.containsKey(token) ) return _isMaterial.get(token);
Synset[] synsets = synsetsOf(token, POS.NOUN);
// System.out.println("isMatter top " + token);
if( synsets == null ) {
}
else {
for( Synset synset : synsets ) {
List<Synset> chain = hypernymChainKeepChild(synset);
if( chain != null ) {
for( Synset parent : chain ) {
Word[] words = parent.getWords();
if( words.length >= 1 && words[0].getLemma().equals("material") ) {
_isMaterial.put(token, true);
return true;
}
}
}
}
}
_isMaterial.put(token, false);
return false;
}
示例3: getNeighborSensedWords
import net.didion.jwnl.data.Word; //导入依赖的package包/类
public Set<SensedWord> getNeighborSensedWords(WordNetRelation relation) throws WordNetException {
Set<SensedWord> sensedWords = new HashSet<SensedWord>();
if (relation.isLexical())
{
PointerType pointerType = JwnlUtils.wordNetRelationToPointerType(relation);
if (pointerType != null)
{
Pointer[] pointers = wordObj.getPointers(pointerType);
for (Pointer pointer : pointers)
try { sensedWords.add( new JwnlSensedWord(((Word) pointer.getTarget()), dictionary)); }
catch (JWNLException e) { throw new WordNetException("See nested",e); }
}
}
return sensedWords;
}
示例4: getWords
import net.didion.jwnl.data.Word; //导入依赖的package包/类
private List<String> getWords(Synset ss) {
List<String> ssWords = new ArrayList<String>();
for (Word w : ss.getWords()) {
ssWords.add(w.getLemma().replaceAll("_", " "));
}
return ssWords;
}
示例5: wordsInSynset
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* @return All lemmas that are under the given synset.
*/
public List<String> wordsInSynset(Synset synset) {
List<String> strings = new ArrayList<String>();
Word[] words = synset.getWords();
for( Word word : words )
strings.add(word.getLemma());
return strings;
}
示例6: getVerbsOfNominalization
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* Gets all of the verbs that are in the synset of which the given noun token
* has a nominalization pointer to.
* @param token A noun e.g. explosion
* @return A list of strings that are verbs e.g. explode, detonate
*/
public List<String> getVerbsOfNominalization(String token) {
Synset[] synsets = synsetsOf(token, POS.NOUN);
if( synsets != null ) {
for( Synset synset : synsets ) {
Pointer[] links = synset.getPointers();
if( links != null ) {
for( Pointer link : links ) {
// Found a link from this noun as a Nominalization to another.
if( link.getType() == PointerType.NOMINALIZATION ) {
// Check that the nominalized word is a verb (e.g. not an adjective).
try {
Synset target = link.getTargetSynset();
if( target.getPOS() == POS.VERB ) {
Synset verbSynset = link.getTargetSynset();
Word[] verbs = verbSynset.getWords();
List<String> theverbs = new ArrayList<String>();
for( Word verb : verbs )
theverbs.add(verb.getLemma());
return theverbs;
}
} catch( Exception ex ) { ex.printStackTrace(); }
}
}
}
}
}
return null;
}
示例7: isSocialGroupSynset
import net.didion.jwnl.data.Word; //导入依赖的package包/类
private boolean isSocialGroupSynset(Synset synset) {
if( synset != null ) {
Word[] words = synset.getWords();
if( words.length > 0 && words[0].getLemma().equals("social_group") )
return true;
}
return false;
}
示例8: isLocationSynset
import net.didion.jwnl.data.Word; //导入依赖的package包/类
private boolean isLocationSynset(Synset synset) {
if( synset != null ) {
Word[] words = synset.getWords();
if( words.length > 0 &&
(words[0].getLemma().equals("location") || words[0].getLemma().equals("road")) )
return true;
}
return false;
}
示例9: isPersonSynset
import net.didion.jwnl.data.Word; //导入依赖的package包/类
private boolean isPersonSynset(Synset synset) {
if( synset != null ) {
Word[] words = synset.getWords();
if( words.length > 0 && words[0].getLemma().equals("person") )
return true;
}
return false;
}
示例10: isPhysicalObjectSynset
import net.didion.jwnl.data.Word; //导入依赖的package包/类
private boolean isPhysicalObjectSynset(Synset synset) {
if( synset != null ) {
Word[] words = synset.getWords();
if( words.length >= 2 &&
(words[1].getLemma().equals("physical_object") || words[0].getLemma().equals("physical_object")) )
return true;
}
return false;
}
示例11: isTimeSynset
import net.didion.jwnl.data.Word; //导入依赖的package包/类
public boolean isTimeSynset(Synset synset) {
if( synset != null ) {
Word[] words = synset.getWords();
if( words.length >= 1 &&
(words[0].getLemma().equals("time_period") || words[0].getLemma().equals("time") || words[0].getLemma().equals("time_unit")) )
return true;
}
return false;
}
示例12: isStructure
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* A more precise lookup of physical structures (more precise than all physical objects)
*/
public boolean isStructure(String token) {
if( _isStructure == null ) _isStructure = new HashMap<String, Boolean>();
if( _isStructure.containsKey(token) ) return _isStructure.get(token);
Synset[] synsets = synsetsOf(token, POS.NOUN);
// System.out.println("isNounEntity top " + token);
if( synsets == null ) {
// System.out.println("isNounEntity null synsets: " + token);
}
else {
for( Synset synset : synsets ) {
List<Synset> chain = hypernymChainKeepChild(synset);
if( chain != null ) {
for( Synset parent : chain ) {
// System.out.println("\t" + parent);
Word[] words = parent.getWords();
if( words.length > 0 && words[0].getLemma().equals("structure") ) {
_isStructure.put(token, true);
return true;
}
}
}
}
}
_isStructure.put(token, false);
return false;
}
示例13: isMeasure
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* Assumes the given token is a noun.
* @return true if the token has a synset with an ancestor that is the Event
* synset.
*/
public boolean isMeasure(String token) {
// save time with a table lookup
if( _isMeasure == null ) _isMeasure = new HashMap<String, Boolean>();
if( _isMeasure.containsKey(token) ) return _isMeasure.get(token);
Synset[] synsets = synsetsOf(token, POS.NOUN);
// System.out.println("isPhysicalObject top " + token);
if( synsets == null ) {
// System.out.println("isNounEvent null synsets: " + token);
}
else {
for( Synset synset : synsets ) {
List<Synset> chain = hypernymChainKeepChild(synset);
if( chain != null ) {
for( Synset parent : chain ) {
// System.out.println("parent = " + parent);
Word[] words = parent.getWords();
if( words.length >= 1 &&
words[0].getLemma().equals("measure") ) {
_isMeasure.put(token, true);
return true;
}
}
}
}
}
_isMeasure.put(token, false);
return false;
}
示例14: isNounEvent
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* Assumes the given token is a noun.
* @return true if the token has a synset with an ancestor that is the Event
* synset.
*/
public boolean isNounEvent(String token) {
// save time with a table lookup
if( _isNounEvent == null ) _isNounEvent = new HashMap<String, Boolean>();
if( _isNounEvent.containsKey(token) ) return _isNounEvent.get(token);
Synset[] synsets = synsetsOf(token, POS.NOUN);
// System.out.println("isNounEvent top " + token);
if( synsets == null ) {
// System.out.println("isNounEvent null synsets: " + token);
}
else {
for( Synset synset : synsets ) {
List<Synset> chain = hypernymChainKeepChild(synset);
if( chain != null ) {
for( Synset parent : chain ) {
Word[] words = parent.getWords();
if( words.length == 1 && words[0].getLemma().equals("event") ) {
_isNounEvent.put(token, true);
return true;
}
}
}
}
}
_isNounEvent.put(token, false);
return false;
}
示例15: JwnlSensedWord
import net.didion.jwnl.data.Word; //导入依赖的package包/类
/**
* Ctor
* @param synset
* @param strWord
* @throws WordNetException
*/
public JwnlSensedWord(JwnlSynset synset, String strWord) throws WordNetException {
this.synset = synset;
this.word = strWord;
String wordToLookup = strWord.replace(' ', '_'); // mimic jwnl, which replaces underscores with spaces when looking up
Word[] words = synset.realSynset.getWords();
Word wordObj = lookupWordInWords(words, wordToLookup);
if (wordObj == null)
throw new WordNetException("\""+ strWord + "\" is not a memeber of the given synset " + synset);
this.wordObj = wordObj;
dictionary = synset.jwnlDictionary;
this.pos = JwnlUtils.getWordNetPartOfSpeech( wordObj.getPOS());
}