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

推荐阅读
  • 本文介绍如何使用MFC和ADO技术调用SQL Server中的存储过程,以查询指定小区在特定时间段内的通话统计数据。通过用户界面选择小区ID、开始时间和结束时间,系统将计算并展示小时级的通话量、拥塞率及半速率通话比例。 ... [详细]
  • 2018-2019学年第六周《Java数据结构与算法》学习总结
    本文总结了2018-2019学年第六周在《Java数据结构与算法》课程中的学习内容,重点介绍了非线性数据结构——树的相关知识及其应用。 ... [详细]
  • 深入解析SpringMVC核心组件:DispatcherServlet的工作原理
    本文详细探讨了SpringMVC的核心组件——DispatcherServlet的运作机制,旨在帮助有一定Java和Spring基础的开发人员理解HTTP请求是如何被映射到Controller并执行的。文章将解答以下问题:1. HTTP请求如何映射到Controller;2. Controller是如何被执行的。 ... [详细]
  • 探讨ChatGPT在法律和版权方面的潜在风险及影响,分析其作为内容创造工具的合法性和合规性。 ... [详细]
  • 本文详细探讨了 org.apache.hadoop.ha.HAServiceTarget 类中的 checkFencingConfigured 方法,包括其功能、应用场景及代码示例。通过实际代码片段,帮助开发者更好地理解和使用该方法。 ... [详细]
  • 本文介绍如何在Spring Boot项目中集成Redis,并通过具体案例展示其配置和使用方法。包括添加依赖、配置连接信息、自定义序列化方式以及实现仓储接口。 ... [详细]
  • Coursera ML 机器学习
    2019独角兽企业重金招聘Python工程师标准线性回归算法计算过程CostFunction梯度下降算法多变量回归![选择特征](https:static.oschina.n ... [详细]
  • 深入理解Java字符串池机制
    本文详细解析了Java中的字符串池(String Pool)机制,探讨其工作原理、实现方式及其对性能的影响。通过具体的代码示例和分析,帮助读者更好地理解和应用这一重要特性。 ... [详细]
  • 本文深入探讨了SQL数据库中常见的面试问题,包括如何获取自增字段的当前值、防止SQL注入的方法、游标的作用与使用、索引的形式及其优缺点,以及事务和存储过程的概念。通过详细的解答和示例,帮助读者更好地理解和应对这些技术问题。 ... [详细]
  • 实用正则表达式有哪些
    小编给大家分享一下实用正则表达式有哪些,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下 ... [详细]
  • 主板IO用W83627THG,用VC如何取得CPU温度,系统温度,CPU风扇转速,VBat的电压. ... [详细]
  • 本文探讨了如何在 F# Interactive (FSI) 中通过 AddPrinter 和 AddPrintTransformer 方法自定义类型(尤其是集合类型)的输出格式,提供了详细的指南和示例代码。 ... [详细]
  • 本文介绍如何从字符串中移除大写、小写、特殊、数字和非数字字符,并提供了多种编程语言的实现示例。 ... [详细]
  • 本文详细介绍了Hive中用于日期和字符串相互转换的多种函数,包括从时间戳到日期格式的转换、日期到时间戳的转换,以及如何处理不同格式的日期字符串。通过这些函数,用户可以轻松实现日期和字符串之间的灵活转换,满足数据处理中的各种需求。 ... [详细]
  • ElasticSearch 集群监控与优化
    本文详细介绍了如何有效地监控 ElasticSearch 集群,涵盖了关键性能指标、集群健康状况、统计信息以及内存和垃圾回收的监控方法。 ... [详细]
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社区 版权所有