本文整理汇总了Java中it.unitn.disi.smatch.data.ling.ISense类的典型用法代码示例。如果您正苦于以下问题:Java ISense类的具体用法?Java ISense怎么用?Java ISense使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ISense类属于it.unitn.disi.smatch.data.ling包,在下文中一共展示了ISense类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSenses
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public List<ISense> getSenses(String label) throws LinguisticOracleException {
List<ISense> result = Collections.emptyList();
try {
IndexWordSet lemmas = dic.lookupAllIndexWords(label);
if (null != lemmas && 0 < lemmas.size()) {
result = new ArrayList<>(lemmas.size());
for (POS pos : POS.values()) {
IndexWord indexWord = lemmas.getIndexWord(pos);
if (null != indexWord) {
for (Synset synset : indexWord.getSenses()) {
result.add(new WordNetSense(synset));
}
}
}
}
} catch (JWNLException e) {
throw new LinguisticOracleException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
return result;
}
示例2: isSourceSynonymTarget
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public boolean isSourceSynonymTarget(ISense source, ISense target) throws SenseMatcherException {
if (source.equals(target)) {
return true;
}
if ((source instanceof WordNetSense) && (target instanceof WordNetSense)) {
try {
WordNetSense sourceSyn = (WordNetSense) source;
WordNetSense targetSyn = (WordNetSense) target;
//is synonym
RelationshipList list = RelationshipFinder.findRelationships(sourceSyn.getSynset(), targetSyn.getSynset(), PointerType.SIMILAR_TO);
if (list.size() > 0) {
return !((POS.ADJECTIVE == sourceSyn.getPOS()) || (POS.ADJECTIVE == targetSyn.getPOS())) || (list.get(0).getDepth() == 0);
}
} catch (CloneNotSupportedException | JWNLException e) {
throw new SenseMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
return false;
}
示例3: isSourceOppositeToTarget
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public boolean isSourceOppositeToTarget(ISense source, ISense target) throws SenseMatcherException {
if (source.equals(target)) {
return false;
}
if ((source instanceof WordNetSense) && (target instanceof WordNetSense)) {
try {
WordNetSense sourceSyn = (WordNetSense) source;
WordNetSense targetSyn = (WordNetSense) target;
// Checks whether senses are siblings (thus they are opposite)
if (POS.NOUN != sourceSyn.getPOS() || POS.NOUN != targetSyn.getPOS()) {
RelationshipList list = RelationshipFinder.findRelationships(sourceSyn.getSynset(), targetSyn.getSynset(), PointerType.ANTONYM);
if (list.size() > 0) {
return true;
}
}
} catch (CloneNotSupportedException | JWNLException e) {
throw new SenseMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
return false;
}
示例4: createSense
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public ISense createSense(String id) throws LinguisticOracleException {
if (id.length() < 3 || 1 != id.indexOf('#')) {
throw new LinguisticOracleException("Malformed sense id: " + id);
}
final String pos = id.substring(0, 1);
final String off = id.substring(2);
if (!"navr".contains(pos) || !offset.matcher(off).matches()) {
throw new LinguisticOracleException("Malformed sense id: " + id);
}
try {
Synset synset = dic.getSynsetAt(POS.getPOSForKey(pos), Long.parseLong(off));
if (null == synset) {
throw new LinguisticOracleException("Synset not found: " + id);
}
return new WordNetSense(synset);
} catch (JWNLException e) {
throw new LinguisticOracleException(e.getMessage(), e);
}
}
示例5: getParents
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public List<ISense> getParents(int depth) throws LinguisticOracleException {
List<ISense> out = new ArrayList<>();
try {
PointerTargetTree hypernyms = PointerUtils.getHypernymTree(synset, depth);
for (Iterator itr = hypernyms.toList().iterator(); itr.hasNext(); ) {
if (itr.hasNext()) {
for (Object o : ((PointerTargetNodeList) itr.next())) {
Synset t = ((PointerTargetNode) o).getSynset();
if (!synset.equals(t)) {
out.add(new WordNetSense(t));
}
}
}
}
} catch (JWNLException e) {
throw new LinguisticOracleException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
return out;
}
示例6: getChildren
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public List<ISense> getChildren(int depth) throws LinguisticOracleException {
List<ISense> out = new ArrayList<>();
try {
PointerTargetTree hypernyms = PointerUtils.getHyponymTree(synset, depth);
for (Iterator itr = hypernyms.toList().iterator(); itr.hasNext(); ) {
if (itr.hasNext()) {
for (Object o : ((PointerTargetNodeList) itr.next())) {
Synset t = ((PointerTargetNode) o).getSynset();
if (!synset.equals(t)) {
out.add(new WordNetSense(t));
}
}
}
}
} catch (JWNLException e) {
throw new LinguisticOracleException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
return out;
}
示例7: isWordMoreGeneral
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
/**
* Checks the source is more general than the target or not.
*
* @param source sense of source
* @param target sense of target
* @return true if the source is more general than target
* @throws it.unitn.disi.smatch.matchers.element.ElementMatcherException ElementMatcherException
*/
public boolean isWordMoreGeneral(String source, String target) throws ElementMatcherException {
try {
List<ISense> sSenses = linguisticOracle.getSenses(source);
List<ISense> tSenses = linguisticOracle.getSenses(target);
for (ISense sSense : sSenses) {
for (ISense tSense : tSenses) {
if (senseMatcher.isSourceMoreGeneralThanTarget(sSense, tSense))
return true;
}
}
return false;
} catch (LinguisticOracleException | SenseMatcherException e) {
throw new ElementMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例8: isWordLessGeneral
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
/**
* Checks the source is less general than the target or not.
*
* @param source sense of source
* @param target sense of target
* @return true if the source is less general than target
* @throws it.unitn.disi.smatch.matchers.element.ElementMatcherException ElementMatcherException
*/
public boolean isWordLessGeneral(String source, String target) throws ElementMatcherException {
try {
List<ISense> sSenses = linguisticOracle.getSenses(source);
List<ISense> tSenses = linguisticOracle.getSenses(target);
for (ISense sSense : sSenses) {
for (ISense tSense : tSenses) {
if (senseMatcher.isSourceLessGeneralThanTarget(sSense, tSense))
return true;
}
}
return false;
} catch (LinguisticOracleException | SenseMatcherException e) {
throw new ElementMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例9: isWordSynonym
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
/**
* Checks the source and target is synonym or not.
*
* @param source sense of source
* @param target sense of target
* @return true if they are synonym
* @throws it.unitn.disi.smatch.matchers.element.ElementMatcherException ElementMatcherException
*/
public boolean isWordSynonym(String source, String target) throws ElementMatcherException {
try {
List<ISense> sSenses = linguisticOracle.getSenses(source);
List<ISense> tSenses = linguisticOracle.getSenses(target);
for (ISense sSense : sSenses) {
for (ISense tSense : tSenses) {
if (senseMatcher.isSourceSynonymTarget(sSense, tSense))
return true;
}
}
return false;
} catch (LinguisticOracleException | SenseMatcherException e) {
throw new ElementMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例10: isWordOpposite
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
/**
* Checks the source and target is opposite or not.
*
* @param source sense of source
* @param target sense of target
* @return true if they are in opposite relation
* @throws it.unitn.disi.smatch.matchers.element.ElementMatcherException ElementMatcherException
*/
public boolean isWordOpposite(String source, String target) throws ElementMatcherException {
try {
List<ISense> sSenses = linguisticOracle.getSenses(source);
List<ISense> tSenses = linguisticOracle.getSenses(target);
for (ISense sSense : sSenses) {
for (ISense tSense : tSenses) {
if (senseMatcher.isSourceOppositeToTarget(sSense, tSense))
return true;
}
}
return false;
} catch (LinguisticOracleException | SenseMatcherException e) {
throw new ElementMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例11: match
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
/**
* Computes the relations with WordNet gloss comparison matcher.
*
* @param source gloss of source
* @param target gloss of target
* @return synonym or IDK relation
*/
public char match(ISense source, ISense target) {
String sSynset = source.getGloss();
String tSynset = target.getGloss();
StringTokenizer stSource = new StringTokenizer(sSynset, " ,.\"'();");
String lemmaS, lemmaT;
int counter = 0;
while (stSource.hasMoreTokens()) {
StringTokenizer stTarget = new StringTokenizer(tSynset, " ,.\"'();");
lemmaS = stSource.nextToken();
if (!meaninglessWords.contains(lemmaS))
while (stTarget.hasMoreTokens()) {
lemmaT = stTarget.nextToken();
if (!meaninglessWords.contains(lemmaT))
if (lemmaS.equals(lemmaT))
counter++;
}
}
if (counter >= threshold)
return IMappingElement.EQUIVALENCE;
else
return IMappingElement.IDK;
}
示例12: senseFilteringAmong
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
protected void senseFilteringAmong(Iterator<INode> i, ISense sourceSense, IAtomicConceptOfLabel sourceACoL,
Map<IAtomicConceptOfLabel, List<ISense>> refinedSenses) throws ContextPreprocessorException {
try {
while (i.hasNext()) {
INode targetNode = i.next();
for (IAtomicConceptOfLabel targetACoL : targetNode.nodeData().getConcepts()) {
if (!refinedSenses.containsKey(targetACoL)) {
for (ISense targetSense : targetACoL.getSenses()) {
// Check whether each sense not synonym or more general, less general then the senses of
// the ancestors and descendants of the node in context hierarchy
if ((senseMatcher.isSourceSynonymTarget(sourceSense, targetSense)) ||
(senseMatcher.isSourceLessGeneralThanTarget(sourceSense, targetSense)) ||
(senseMatcher.isSourceMoreGeneralThanTarget(sourceSense, targetSense))) {
addToRefinedSenses(refinedSenses, sourceACoL, sourceSense);
addToRefinedSenses(refinedSenses, targetACoL, targetSense);
}
}
}
}
}
} catch (SenseMatcherException e) {
throw new ContextPreprocessorException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例13: getRelationFromSenseGlossMatchers
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
/**
* Returns semantic relation between two sets of senses by WordNet sense-based matchers.
*
* @param sourceSenses source senses
* @param targetSenses target senses
* @return semantic relation between two sets of senses
* @throws MatcherLibraryException MatcherLibraryException
*/
private char getRelationFromSenseGlossMatchers(List<ISense> sourceSenses, List<ISense> targetSenses) throws MatcherLibraryException {
char relation = IMappingElement.IDK;
if (0 < senseGlossMatchers.size()) {
for (ISense sourceSense : sourceSenses) {
//noinspection LoopStatementThatDoesntLoop
for (ISense targetSense : targetSenses) {
int k = 0;
while ((relation == IMappingElement.IDK) && (k < senseGlossMatchers.size())) {
relation = senseGlossMatchers.get(k).match(sourceSense, targetSense);
k++;
}
return relation;
}
}
}
return relation;
}
示例14: getSenses
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public List<ISense> getSenses(String label) throws LinguisticOracleException {
List<ISense> result = new ArrayList<ISense>();
try {
IndexWordSet lemmas = dic.lookupAllIndexWords(label);
if (null != lemmas && 0 < lemmas.size()) {
//Looping on all words in indexWordSet
for (int i = 0; i < lemmas.getIndexWordArray().length; i++) {
IndexWord lemma = lemmas.getIndexWordArray()[i];
for (int j = 0; j < lemma.getSenses().size(); j++) {
Synset synset = lemma.getSenses().get(j);
result.add(new WordNetSense(synset));
}
}
}
} catch (JWNLException e) {
final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
log.error(errMessage, e);
throw new LinguisticOracleException(errMessage, e);
}
return result;
}
示例15: isSourceSynonymTarget
import it.unitn.disi.smatch.data.ling.ISense; //导入依赖的package包/类
public boolean isSourceSynonymTarget(ISense source, ISense target) throws SenseMatcherException {
if (source.equals(target)) {
return true;
}
if ((source instanceof WordNetSense) && (target instanceof WordNetSense)) {
try {
WordNetSense sourceSyn = (WordNetSense) source;
WordNetSense targetSyn = (WordNetSense) target;
//is synonym
RelationshipList list = RelationshipFinder.findRelationships(sourceSyn.getSynset(), targetSyn.getSynset(), PointerType.SIMILAR_TO);
if (list.size() > 0) {
return !((POS.ADJECTIVE == sourceSyn.getPOS()) || (POS.ADJECTIVE == targetSyn.getPOS())) || (list.get(0).getDepth() == 0);
}
} catch (CloneNotSupportedException e) {
final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
log.error(errMessage, e);
throw new SenseMatcherException(errMessage, e);
}
}
return false;
}