热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何使用net.sf.extjwnl.data.Word类及其代码示例详解

本文整理了Java中net.sf.extjwnl.data.Word类的一些代码示例,展示了Word类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从

本文整理了Java中net.sf.extjwnl.data.Word类的一些代码示例,展示了Word类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Word类的具体详情如下:
包路径:net.sf.extjwnl.data.Word
类名称: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(List words, String wordToLookup) {
boolean found = false;
Word someWord = null;
for (int i = 0; i {
someWord = words.get(i);
found = someWord.getLemma().equalsIgnoreCase(wordToLookup);
}
return someWord;
}
}

代码示例来源:origin: extjwnl/extjwnl

private static int getSenseNo(final Word word) throws JWNLException {
final IndexWord iw = word.getDictionary().getIndexWord(word.getPOS(), word.getLemma());
for (int i = 0; i if (iw.getSenses().get(i).getOffset() == word.getSynset().getOffset()) {
return i;
}
}
return -1;
}

代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.integration.wordnet-gpl

@Override
public int compare(Word o1, Word o2) {
return o1.getSenseKey().compareTo(o2.getSenseKey());
}
});

代码示例来源:origin: extjwnl/extjwnl

/**
* Two words are equal if their parent Synsets are equal and they have the same lemma
*/
public boolean equals(Object object) {
return (object instanceof Word)
&& ((Word) object).getSynset().equals(getSynset())
&& ((Word) object).getLemma().equals(getLemma());
}

代码示例来源:origin: extjwnl/extjwnl

public String toString() {
return ResourceBundleSet.insertParams("[Word: {0} [Lemma: {1}] {2} [Index: {3}]]", new Object[]{getPOS(), getLemma(), getSynset(), getIndex()});
}

代码示例来源:origin: net.sf.extjwnl/extjwnl

private static int getUseCount(Synset synset, String lemma) {
for (Word w : synset.getWords()) {
if (w.getLemma().equalsIgnoreCase(lemma)) {
if (0 return w.getUseCount();
}
}
}
return 0;
}

代码示例来源:origin: apache/opennlp-sandbox

public static String getMostFrequentSense(WSDSample sample) {
List synsets = sample.getSynsets();
for (Word wd : synsets.get(0).getWords()) {
if (wd.getLemma()
.equalsIgnoreCase((sample.getLemmas()[sample.getTargetPosition()]))) {
try {
return WSDParameters.SenseSource.WORDNET.name() + " "
+ wd.getSenseKey();
} catch (JWNLException e) {
e.printStackTrace();
}
}
}
return "nonesense";
}

代码示例来源:origin: net.sf.extjwnl/extjwnl-utilities

log.error("Duplicate sensekey for -add: {}", workWord.getSenseKey());
System.exit(1);
final Synset tempSynset = d.createSynset(pos);
log.info("Creating word {}...", lemma);
workWord = new Word(d, tempSynset, lemma);
workWord.setLexId(lexId);
tempSynset.getWords().add(workWord);
tempSynset.setLexFileNum(lexFileNum);
d.removeSynset(workWord.getSynset());
workWord = null;
key = null;
final Word tempWord = new Word(d, workWord.getSynset(), args[i].replace('_', ' '));
workWord.getSynset().getWords().add(tempWord);
key = null;
} else {
log.error("Missing word for addword command for sensekey {}", workWord.getSenseKey());
System.exit(1);
workWord.getSynset().getWords().remove(workWord);
key = null;
workWord.getSynset().setGloss(args[i]);
key = null;
} else {
log.error("Missing gloss for setgloss command for sensekey {}", workWord.getSenseKey());
System.exit(1);

代码示例来源:origin: net.sf.extjwnl/extjwnl

return o1.getSenseKeyWithAdjClass().compareTo(o2.getSenseKeyWithAdjClass());
} catch (JWNLException e) {
throw new JWNLRuntimeException(e);
s.append(word.getSenseKeyWithAdjClass()).
append(' ').append(word.getSenseNumber()).
append(' ').append(word.getUseCount());
int result = o2.getUseCount() - o1.getUseCount();
if (0 == result) {
try {
result = o2.getSenseKeyWithAdjClass().compareTo(o1.getSenseKeyWithAdjClass());
} catch (JWNLException e) {
throw new JWNLRuntimeException(e);
s.append(word.getUseCount()).
append(' ').append(word.getSenseKeyWithAdjClass()).
append(' ').append(word.getSenseNumber());
Synset synset = iw.getSenses().get(i);
for (Word w : synset.getWords()) {
if (w.getLemma().equalsIgnoreCase(iw.getLemma())) {
result.delete(0, result.length());
result.append(w.getSenseKey()).append(" ");
formatOffset(synset.getOffset(), offsetLength, result);
result.append(" ");
result.append(i + 1);
result.append(" ");

代码示例来源:origin: hltfbk/Excitement-Open-Platform

/**
* Ctor with an {@link Word} and a dictionary
* This Ctor is quicker than the other.
* @param jwiDictionary
* @throws WordNetException
*/
ExtJwnlSensedWord(Word wordObj, ExtJwnlDictionary extJwnlDictionary) throws WordNetException {
if (wordObj==null)
throw new WordNetException("wordObj is null!");
this.wordObj = wordObj;
this.synset = new ExtJwnlSynset(extJwnlDictionary, wordObj.getSynset());
this.word = wordObj.getLemma();
this.dictiOnary= extJwnlDictionary;
this.pos = ExtJwnlUtils.getWordNetPartOfSpeech( wordObj.getPOS());
}

代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.integration.wordnet-gpl

if(!posSet){
lexicalEntry.setPartOfSpeech(WNConvUtil.getPOS(lexeme.getPOS()));
posSet = true;
lemmaString = lexeme.getLemma();
if(lePOS.equals(EPartOfSpeech.verb)){
String[] frames = lexeme.getSynset().getVerbFrames();
for(String frame : frames){
Map codeLexeme = new TreeMap();
if(lePOS.equals(EPartOfSpeech.adjective) && (synMarker = lexeme.getSenseKeyWithAdjClass()).contains("(")){
int start = synMarker.indexOf("(");
String adjFrameCode = synMarker.substring(start+1, synMarker.indexOf(")"));

代码示例来源:origin: net.sf.extjwnl/extjwnl

/**
* Returns the sense key of a lemma.
*
* @return sense key
* @throws JWNLException JWNLException
*/
public String getSenseKey() throws JWNLException {
int ss_type = getSynsetType();
final StringBuilder senseKey = startBuildingSenseKey(ss_type);
if (POS.ADJECTIVE_SATELLITE_ID == ss_type) {
List p = synset.getPointers(PointerType.SIMILAR_TO);
if (0 Pointer headWord = p.get(0);
List words = headWord.getTargetSynset().getWords();
if (0 Word word = words.get(0);
senseKey.append(word.getLemma().toLowerCase().replace(' ', '_')).append(":");
if (word.getLexId() <10) {
senseKey.append("0");
}
senseKey.append(word.getLexId());
}
}
} else {
senseKey.append(":");
}
return senseKey.toString();
}

代码示例来源:origin: net.sf.extjwnl/extjwnl-utilities

synsetWordStmt.setInt(1, wordId);
synsetWordStmt.setString(3, word.getLemma());
synsetWordStmt.setInt(4, word.getIndex());
synsetWordStmt.setInt(5, word.getUseCount());
synsetWordStmt.setLong(6, word.getLexId());
synsetVerbFrameStmt.setInt(4, word.getIndex());
BitSet bits = ((Verb) word).getVerbFrameFlags();
for (int i = bits.nextSetBit(0); i >= 0; i = bits.nextSetBit(i + 1)) {

代码示例来源:origin: extjwnl/extjwnl

for (int i = 0; i final Word word = words.get(i);
System.out.print(word.getLemma());
if (needLex && 0 System.out.print(word.getLexId());
System.out.print(" [" + word.getSenseKey() + "]");

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.wsd/de.tudarmstadt.ukp.dkpro.wsd.si.wordnet

public CachedSense(String senseId)
throws SenseInventoryException
{
super(senseId);
try {
word = wn.getWordBySenseKey(senseId);
synset = word.getSynset();
pos = wordNetPosToSiPos.transform(word.getPOS());
useCount = word.getUseCount();
}
catch (JWNLException e) {
throw new SenseInventoryException(e);
}
}

代码示例来源:origin: extjwnl/extjwnl

private void addToIndexWords(Word word) {
if (null != dictionary && dictionary.isEditable()) {
try {
IndexWord iw = dictionary.getIndexWord(word.getPOS(), word.getLemma());
if (null == iw) {
dictionary.createIndexWord(word.getPOS(), word.getLemma(), Synset.this);
} else {
if (!iw.getSenses().contains(Synset.this)) {
iw.getSenses().add(Synset.this);
}
}
} catch (JWNLException e) {
throw new JWNLRuntimeException(e);
}
}
}
}

代码示例来源:origin: net.sf.extjwnl/extjwnl

for (Synset sense : iw.getSenses()) {
for (Word word : sense.getWords()) {
if (word.getLemma().equalsIgnoreCase(iw.getLemma())) {
List list = words.computeIfAbsent(sense.getLexFileNum(), k -> new ArrayList<>());
list.add(word);
int maxId = -1;
for (Word word : list) {
if (maxId maxId = word.getLexId();
if (-1 == word.getLexId()) {
maxId++;
word.setLexId(maxId);

代码示例来源:origin: net.sf.extjwnl/extjwnl

protected int getSynsetType() {
int ss_type = getPOS().getId();
if (POS.ADJECTIVE == getSynset().getPOS() && getSynset().isAdjectiveCluster()) {
ss_type = POS.ADJECTIVE_SATELLITE_ID;
}
return ss_type;
}

代码示例来源:origin: net.sf.extjwnl/extjwnl

String lemma = w.getLemma().replace(' ', '_');
if (w instanceof Adjective) {
Adjective a = (Adjective) w;
if (checkLexIdLimit && log.isWarnEnabled() && (0xF log.warn(dictionary.getMessages().resolveMessage("PRINCETON_WARN_005",
new Object[]{synset.getOffset(), w.getLemma(), w.getLexId()}));
result.append(Long.toHexString(w.getLexId())).append(' ');
for (int i = bits.nextSetBit(0); i >= 0; i = bits.nextSetBit(i + 1)) {
if (!verbFrames.get(i)) {
if (checkVerbFrameLimit && log.isWarnEnabled() && (0xFF log.warn(dictionary.getMessages().resolveMessage("PRINCETON_WARN_008",
new Object[]{synset.getOffset(), word.getIndex()}));
if (word.getIndex() <0x10) {
result.append("0");
result.append(Integer.toHexString(word.getIndex())).append(' ');

代码示例来源:origin: de.tudarmstadt.ukp.uby/de.tudarmstadt.ukp.uby.integration.wordnet-gpl

sense.setLexicalEntry(lexicalEntry);
String senseNumber = isr.getSenseNumber(lexeme.getSenseKey());
if(senseNumber != null){
int index = Integer.parseInt(senseNumber);
StringBuffer sb = new StringBuffer(128);
sb.append("IndexSenseReader did not provide sense number for senseKey ");
sb.append(lexeme.getSenseKey()).append('\n');
sb.append("adding a dummy value of sense number");
logger.warn(sb.toString());
net.sf.extjwnl.data.Synset lexemeSynset = lexeme.getSynset(); // lexemes Synset
sb.append(lexeme.getSynset().getPOS());
sb.append(" ");
sb.append(lexeme.getSenseKey());
monolingualExternalRef.setExternalSystem("WordNet 3.0 part of speech and sense key");
monolingualExternalRef.setExternalReference(sb.toString());

推荐阅读
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 尽管使用TensorFlow和PyTorch等成熟框架可以显著降低实现递归神经网络(RNN)的门槛,但对于初学者来说,理解其底层原理至关重要。本文将引导您使用NumPy从头构建一个用于自然语言处理(NLP)的RNN模型。 ... [详细]
  • 本文详细介绍了Java中org.neo4j.helpers.collection.Iterators.single()方法的功能、使用场景及代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • 本文介绍了如何通过 Maven 依赖引入 SQLiteJDBC 和 HikariCP 包,从而在 Java 应用中高效地连接和操作 SQLite 数据库。文章提供了详细的代码示例,并解释了每个步骤的实现细节。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • 本章将深入探讨移动 UI 设计的核心原则,帮助开发者构建简洁、高效且用户友好的界面。通过学习设计规则和用户体验优化技巧,您将能够创建出既美观又实用的移动应用。 ... [详细]
  • 本文详细介绍了macOS系统的核心组件,包括如何管理其安全特性——系统完整性保护(SIP),并探讨了不同版本的更新亮点。对于使用macOS系统的用户来说,了解这些信息有助于更好地管理和优化系统性能。 ... [详细]
author-avatar
木_妍_595
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有