当前位置: 首页>>代码示例>>Java>>正文


Java LinguisticOracleException类代码示例

本文整理汇总了Java中it.unitn.disi.smatch.oracles.LinguisticOracleException的典型用法代码示例。如果您正苦于以下问题:Java LinguisticOracleException类的具体用法?Java LinguisticOracleException怎么用?Java LinguisticOracleException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LinguisticOracleException类属于it.unitn.disi.smatch.oracles包,在下文中一共展示了LinguisticOracleException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSenses

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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;
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:21,代码来源:WordNet.java

示例2: isEqual

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的package包/类
public boolean isEqual(String str1, String str2) throws LinguisticOracleException {
    try {
        IndexWordSet lemmas1 = dic.lookupAllIndexWords(str1);
        IndexWordSet lemmas2 = dic.lookupAllIndexWords(str2);
        if ((lemmas1 == null) || (lemmas2 == null) || (lemmas1.size() < 1) || (lemmas2.size() < 1)) {
            return false;
        } else {
            IndexWord[] v1 = lemmas1.getIndexWordArray();
            IndexWord[] v2 = lemmas2.getIndexWordArray();
            for (IndexWord aV1 : v1) {
                for (IndexWord aV2 : v2) {
                    if (aV1.equals(aV2)) {
                        return true;
                    }
                }
            }
        }
    } catch (JWNLException e) {
        throw new LinguisticOracleException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
    return false;
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:23,代码来源:WordNet.java

示例3: createSense

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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);
    }
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:20,代码来源:WordNet.java

示例4: getParents

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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;
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:20,代码来源:WordNetSense.java

示例5: getChildren

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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;
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:20,代码来源:WordNetSense.java

示例6: isWordMoreGeneral

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:24,代码来源:BaseGlossMatcher.java

示例7: isWordLessGeneral

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:24,代码来源:BaseGlossMatcher.java

示例8: isWordSynonym

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:24,代码来源:BaseGlossMatcher.java

示例9: isWordOpposite

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:24,代码来源:BaseGlossMatcher.java

示例10: extendedIndexOf

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的package包/类
/**
 * An extension of the list indexOf method which uses approximate comparison of the words as
 * elements of the List.
 *
 * @param vec      list of strings
 * @param str      string to search
 * @param init_pos start position
 * @return position
 * @throws ContextPreprocessorException ContextPreprocessorException
 */
private int extendedIndexOf(List<String> vec, String str, int init_pos) throws ContextPreprocessorException {
    try {
        // for all words in the input list starting from init_pos
        for (int i = init_pos; i < vec.size(); i++) {
            String vel = vec.get(i);
            // try syntactic
            if (vel.equals(str)) {
                return i;
            } else if (vel.indexOf(str) == 0) {
                // and semantic comparison
                if (linguisticOracle.isEqual(vel, str)) {
                    vec.add(i, str);
                    vec.remove(i + 1);
                    return i;
                }
            }
        }
        return -1;
    } catch (LinguisticOracleException e) {
        throw new ContextPreprocessorException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:33,代码来源:DefaultContextPreprocessor.java

示例11: getSenses

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的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;
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:22,代码来源:WordNet.java

示例12: isEqual

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的package包/类
public boolean isEqual(String str1, String str2) throws LinguisticOracleException {
    try {
        IndexWordSet lemmas1 = dic.lookupAllIndexWords(str1);
        IndexWordSet lemmas2 = dic.lookupAllIndexWords(str2);
        if ((lemmas1 == null) || (lemmas2 == null) || (lemmas1.size() < 1) || (lemmas2.size() < 1)) {
            return false;
        } else {
            IndexWord[] v1 = lemmas1.getIndexWordArray();
            IndexWord[] v2 = lemmas2.getIndexWordArray();
            for (IndexWord aV1 : v1) {
                for (IndexWord aV2 : v2) {
                    if (aV1.equals(aV2)) {
                        return true;
                    }
                }
            }
        }
    } catch (JWNLException e) {
        final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
        log.error(errMessage, e);
        throw new LinguisticOracleException(errMessage, e);
    }
    return false;
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:25,代码来源:WordNet.java

示例13: checkMW

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的package包/类
private List<ISense> checkMW(String source, String target) throws ContextPreprocessorException {
    try {
        ArrayList<ArrayList<String>> mwEnds = linguisticOracle.getMultiwords(source);
        if (mwEnds != null) {
            for (ArrayList<String> strings : mwEnds) {
                if (extendedIndexOf(strings, target, 0) > 0) {
                    return linguisticOracle.getSenses(source + " " + target);
                }
            }
        }
        return new ArrayList<ISense>();
    } catch (LinguisticOracleException e) {
        final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
        log.error(errMessage, e);
        throw new ContextPreprocessorException(errMessage, e);
    }
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:18,代码来源:DefaultContextPreprocessor.java

示例14: extendedIndexOf

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的package包/类
/**
 * An extension of the list indexOf method which uses approximate comparison of the words as
 * elements of the List.
 *
 * @param vec      list of strings
 * @param str      string to search
 * @param init_pos start position
 * @return position
 * @throws ContextPreprocessorException ContextPreprocessorException
 */
private int extendedIndexOf(List<String> vec, String str, int init_pos) throws ContextPreprocessorException {
    try {
        // for all words in the input list starting from init_pos
        for (int i = init_pos; i < vec.size(); i++) {
            String vel = vec.get(i);
            // try syntactic
            if (vel.equals(str)) {
                return i;
            } else if (vel.indexOf(str) == 0) {
                // and semantic comparison
                if (linguisticOracle.isEqual(vel, str)) {
                    vec.add(i, str);
                    vec.remove(i + 1);
                    return i;
                }
            }
        }
        return -1;
    } catch (LinguisticOracleException e) {
        final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage();
        log.error(errMessage, e);
        throw new ContextPreprocessorException(errMessage, e);
    }
}
 
开发者ID:opendatatrentino,项目名称:s-match,代码行数:35,代码来源:DefaultContextPreprocessor.java

示例15: getAncestors

import it.unitn.disi.smatch.oracles.LinguisticOracleException; //导入依赖的package包/类
private List<ISense> getAncestors(ISense node, int depth) throws ElementMatcherException {
    try {
        return node.getParents(depth);
    } catch (LinguisticOracleException e) {
        throw new ElementMatcherException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
    }
}
 
开发者ID:s-match,项目名称:s-match-core,代码行数:8,代码来源:WNHierarchy.java


注:本文中的it.unitn.disi.smatch.oracles.LinguisticOracleException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。