热门标签 | 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());

推荐阅读
  • 高效处理大文件:单线程与多线程下的词频统计方法
    本文探讨了在处理大文件时,如何通过单线程和多线程的方式使用Buffer流进行词频统计,以避免一次性加载文件导致的内存溢出问题,并提供了具体的实现代码。 ... [详细]
  • 本文深入探讨了时序分析中的基本概念,包括建立时间、保持时间、时钟偏移等关键参数,并详细解释了这些参数在集成电路设计中的应用及重要性。 ... [详细]
  • 本文详细介绍了 Activiti 引擎中的 JobQuery.withException 方法,并提供了多个实际应用的代码示例,帮助开发者更好地理解和使用该方法。 ... [详细]
  • 本文介绍了如何通过Java代码实现Excel文件的上传,并将其中的数据读取后存储到数据库中。同时,记录了操作日志以确保操作的可追溯性。 ... [详细]
  • Netty基础教程:构建简易Netty客户端与服务器
    Java NIO是解决传统阻塞I/O问题的关键技术之一,但其复杂性给开发者带来了挑战。Netty作为一个成熟的网络编程框架,极大地简化了这一过程。本文将通过一个简单的示例,介绍如何使用Netty创建基本的客户端和服务器。 ... [详细]
  • 本文详细探讨了Laravel框架中的数据库操作,包括读写分离、事务处理、Eloquent ORM的使用、关联关系管理及性能优化技巧。 ... [详细]
  • 本文详细解析了Java面试中常见的问题及答案,旨在帮助求职者更好地准备面试,提高通过率。 ... [详细]
  • 当从数据库查询返回一个(仅向前,只读)ResultSet时,该ResultSet表现得像一个数据库行列表。本文探讨了如何将ResultSet转换成Scala流,以支持高效的数据处理操作。 ... [详细]
  • 本文详细介绍了在MyEclipse和Eclipse中安装和配置Hibernate开发工具的方法,包括所需的插件和具体操作步骤。 ... [详细]
  • 本文详细解释了 Java 编程语言中 @SuppressWarnings 注解的使用方法及其意义,特别是在处理未经检查的类型转换警告时的应用。 ... [详细]
  • Java异常处理之释放资源
    目录一、finally代码块二、自动资源管理一、finally代码块有时在try-catch语句中会占用一些非Java资源,如:打开文件、网络连接、打开数据库连接和 ... [详细]
  • 1整合dubbo1.1e3-manager-Service1.1.1pom.xml排除jar在e3-manager-Service工程中添加dubbo依赖的jar包。 ... [详细]
  • IO包中的其他类【JAVA基础】
    IO包中的其他类管道流:IO流和多线程相结合案例对象的序列化:将学生对象存进硬盘和取出随机访问文件RandomAccessFile类指定读取案例操作基本数据类型的对象 ... [详细]
  • 本文档提供了在iOS开发中使用OClint进行静态代码分析的详细步骤,包括安装、更新和使用方法,以及相关资源链接。 ... [详细]
  • Django Admin 插件详解与应用
    本文介绍了 Django Admin 的主要功能及其在项目开发中的作用,包括如何通过模型类操作数据库、自定义 Admin 方法以及多种配置选项,旨在帮助开发者快速掌握 Django Admin 的使用技巧。 ... [详细]
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社区 版权所有