本文整理了Java中net.didion.jwnl.data.Word
类的一些代码示例,展示了Word
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Word
类的具体详情如下:
包路径:net.didion.jwnl.data.Word
类名称:Word
[英]A Word
represents the lexical information related to a specific sense of an IndexWord
. Word
's are linked by Pointers into a network of lexically related words. #getTargets retrieves the targets of these links, and Word#getPointers retrieves the pointers themselves.
[中]Word
表示与IndexWord
的特定意义相关的词汇信息。Word
通过指针链接到一个词汇相关单词的网络中#getTargets检索这些链接的目标,Word#getPointers检索指针本身。
代码示例来源:origin: hltfbk/Excitement-Open-Platform
/**
* @param words
* @param wordToLookup
* @return
*/
private Word lookupWordInWords(Word[] words, String wordToLookup) {
boolean found = false;
Word someWord = null;
for (int i = 0; i < words.length && !found; i++)
{
someWord = words[i];
found = someWord.getLemma().equalsIgnoreCase(wordToLookup);
}
return someWord;
}
}
代码示例来源:origin: net.sf.jwordnet/jwnl
public String toString() {
if (_cachedToString == null) {
Object[] params = new Object[]{getPOS(), getLemma(), getSynset(), new Integer(getIndex())};
_cachedToString = JWNL.resolveMessage("DATA_TOSTRING_005", params);
}
return _cachedToString;
}
代码示例来源:origin: net.sf.jwordnet/jwnl
/** returns all the pointers of the synset that contains this word whose source is this word */
public Pointer[] getPointers() {
Pointer[] source = getSynset().getPointers();
List list = new ArrayList(source.length);
for (int i = 0; i < source.length; ++i) {
Pointer pointer = source[i];
if (this.equals(pointer.getSource()))
list.add(pointer);
}
return (Pointer[]) list.toArray(new Pointer[list.size()]);
}
}
代码示例来源:origin: net.sf.jwordnet/jwnl
/** Two words are equal if their parent Synsets are equal and they have the same index */
public boolean equals(Object object) {
return (object instanceof Word)
&& ((Word) object).getSynset().equals(getSynset())
&& ((Word) object).getIndex() == getIndex();
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
public long getUsageOf(String word) throws WordNetException
{
long ret = 0;
Word[] wordsOfSynset = this.realSynset.getWords();
for (Word wordOfSynset : wordsOfSynset)
{
if (wordOfSynset.getLemma().equals(word))
{
ret = wordOfSynset.getUsageCount();
}
}
return ret;
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
/**
* Ctor with an {@link Word} and a dictionary
* This Ctor is quicker than the other.
* @param jwiDictionary
* @throws WordNetException
*/
JwnlSensedWord(Word objWord, JwnlDictionary jwnlDictionary) throws WordNetException {
this.wordObj = objWord;
this.synset = new JwnlSynset(jwnlDictionary, objWord.getSynset());
this.word = objWord.getLemma();
this.dictionary = jwnlDictionary;
this.pos = JwnlUtils.getWordNetPartOfSpeech( wordObj.getPOS());
}
代码示例来源:origin: Noahs-ARK/semafor
for(int i=0;i<words.length;i++){
w = words[i];
syn = w.getLemma();
pos = w.getPOS();
for(int j=0;j<words.length;j++){
w = words[j];
lemma = w.getLemma();
pos = w.getPOS();
if(lemma.contains("_")){
String[] parts = lemma.split("_");
lemma = w.getLemma();
pos = w.getPOS();
if(lemma.contains("_")){
String[] parts = lemma.split("_");
代码示例来源:origin: stackoverflow.com
IndexWord word = dictionary.lookupIndexWord(POS.NOUN, exampleWord);
List<Synset> synset=word.getSenses();
int nums = word.sortSenses();
// for each sense of the word
for ( Synset syn : synset) {
// get the synonyms of the sense
PointerTargetTree s = PointerUtils.getSynonymTree(syn, 2 /*depth*/);
List<PointerTargetNodeList> l = s.toList();
for (PointerTargetNodeList nl : l) {
for (PointerTargetNode n : nl) {
Synset ns = n.getSynset();
if (ns!=null) {
List<Word> ws = ns.getWords();
for (Word ww : ws) {
// ww.getUseCount() is the frequency of occurance as reported by wordnet engine
println(ww.getLemma(), ww.getUseCount());
}
}
}
}
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
/**
* 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());
}
代码示例来源:origin: net.sf.jwordnet/jwnl
/**
* If the target is a synset, return it, otherwise it's a word
* so return the word's parent synset.
*/
public Synset getSynset() {
if (isLexical()) {
return ((Word)_target).getSynset();
} else {
return (Synset)_target;
}
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
JwnlSensedWord other = (JwnlSensedWord) obj;
if (wordObj == null) {
if (other.wordObj != null)
return false;
} else if (!wordObj.equals(other.wordObj))
return false;
return true;
}
代码示例来源:origin: net.sf.jwordnet/jwnl
protected Word createWord(Synset synset, int index, String lemma) {
if (synset.getPOS().equals(POS.VERB)) {
return new MutableVerb(synset, index, lemma);
} else {
return new Word(synset, index, lemma);
}
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
ret.add(new WordAndUsage(word.getLemma(), word.getUsageCount()));
代码示例来源:origin: net.sf.jwordnet/jwnl
public int hashCode() {
return getSynset().hashCode() ^ getIndex();
}
代码示例来源:origin: net.sf.jwordnet/jwnl
/**
* Get the synset that is a) the target of this pointer, or b) the * synset that contains the target of this pointer.
*/
public Synset getTargetSynset() throws JWNLException {
PointerTarget target = getTarget();
if (target instanceof Word) {
return ((Word) target).getSynset();
} else {
return (Synset) target;
}
}
代码示例来源:origin: net.sf.jwordnet/jwnl
protected Word createWord(Synset synset, int index, String lemma) {
if (synset.getPOS().equals(POS.VERB)) {
return new MutableVerb(synset, index, lemma);
} else {
return new Word(synset, index, lemma);
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
private void addSynonymFeature(Set<String> f1, Synset synset, WordNetFeatureClass name,
String key) {
if (featureClasses.contains(name)) {
for (Word w : synset.getWords())
f1.add(key + w.getLemma());
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
private void addSynonymFeature(Set<String> f1, Synset synset, WordNetFeatureClass name,
String key) {
if (featureClasses.contains(name)) {
for (Word w : synset.getWords())
f1.add(key + w.getLemma());
}
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
public Set<String> getWords() throws WordNetException
{
if (words == null)
{
words = new HashSet<String>();
for (Word word : this.realSynset.getWords())
{
String lemma = word.getLemma();
lemma = lemma.replaceAll("_", " "); // clean
words.add(lemma);
}
}
return new HashSet<String>(words); // return a copy
}
代码示例来源:origin: eu.fbk.pikes/pikes-resources
public static Set<String> getLemmas(final String synsetID) {
final Set<String> lemmas = Sets.newLinkedHashSet();
final Synset synset = getSynset(synsetID);
if (synset != null) {
for (final Word word : synset.getWords()) {
lemmas.add(word.getLemma());
}
}
return lemmas;
}
内容来源于网络,如有侵权,请联系作者删除!