當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。