本文整理汇总了Java中net.sf.extjwnl.JWNLException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java JWNLException.getMessage方法的具体用法?Java JWNLException.getMessage怎么用?Java JWNLException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.extjwnl.JWNLException
的用法示例。
在下文中一共展示了JWNLException.getMessage方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSenses
import net.sf.extjwnl.JWNLException; //导入方法依赖的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: isEqual
import net.sf.extjwnl.JWNLException; //导入方法依赖的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;
}
示例3: createSense
import net.sf.extjwnl.JWNLException; //导入方法依赖的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);
}
}
示例4: findAdjectiveAntonyms
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findAdjectiveAntonyms(Dictionary dic) throws SMatchException {
log.info("Creating adjective antonyms array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.ADJECTIVE);
while (it.hasNext()) {
count++;
if (0 == count % 1000) {
log.debug("adjective antonyms: " + count);
}
Synset current = it.next();
traverseTree(keys, PointerUtils.getExtendedAntonyms(current), current.getOffset());
traverseListSym(keys, PointerUtils.getAntonyms(current), current.getOffset());
}
log.info("Adjective antonyms: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例5: findNounAntonyms
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findNounAntonyms(Dictionary dic) throws SMatchException {
log.info("Creating noun antonyms array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.NOUN);
while (it.hasNext()) {
count++;
if (0 == count % 10000) {
log.debug("noun antonyms: " + count);
}
Synset source = it.next();
cartPr(keys, source.getPointers(PointerType.PART_MERONYM));
cartPr(keys, source.getPointers(PointerType.SUBSTANCE_MERONYM));
cartPr(keys, source.getPointers(PointerType.MEMBER_MERONYM));
}
log.info("Noun antonyms: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例6: findVerbHypernyms
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findVerbHypernyms(Dictionary dic) throws SMatchException {
log.info("Creating verb hypernyms array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.VERB);
while (it.hasNext()) {
count++;
if (0 == count % 1000) {
log.debug("verb hypernyms: " + count);
}
Synset source = it.next();
long sourceOffset = source.getOffset();
traverseTreeMG(keys, PointerUtils.getHypernymTree(source), sourceOffset);
}
log.info("Verb hypernyms: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例7: getParents
import net.sf.extjwnl.JWNLException; //导入方法依赖的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;
}
示例8: getChildren
import net.sf.extjwnl.JWNLException; //导入方法依赖的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;
}
示例9: collectMultiwords
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static void collectMultiwords(Dictionary dic, Map<String, List<List<String>>> multiwords, POS pos) throws SMatchException {
try {
int count = 0;
Iterator i = dic.getIndexWordIterator(pos);
while (i.hasNext()) {
IndexWord iw = (IndexWord) i.next();
String lemma = iw.getLemma();
if (-1 < lemma.indexOf(' ')) {
count++;
if (0 == count % 10000) {
log.debug("multiwords: " + count);
}
String[] tokens = lemma.split(" ");
List<List<String>> mwEnds = multiwords.get(tokens[0]);
if (null == mwEnds) {
mwEnds = new ArrayList<>();
}
List<String> currentMWEnd = new ArrayList<>(Arrays.asList(tokens));
currentMWEnd.remove(0);
mwEnds.add(currentMWEnd);
multiwords.put(tokens[0], mwEnds);
}
}
log.info(pos.getKey() + " multiwords: " + count);
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例10: findNominalizations
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findNominalizations(Dictionary dic) throws SMatchException {
log.info("Creating nominalizations array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.VERB);
while (it.hasNext()) {
count++;
if (0 == count % 1000) {
log.debug("nominalizations: " + count);
}
Synset source = it.next();
List<Pointer> pointers = source.getPointers(PointerType.DERIVATION);
for (Pointer pointer : pointers) {
if (POS.NOUN.equals(pointer.getTargetPOS())) {
long targetOffset = pointer.getTargetOffset();
long key = (source.getOffset() << 32) + targetOffset;
keys.add(key);
}
}
}
log.info("Nominalizations: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例11: findAdjectiveSynonyms
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findAdjectiveSynonyms(Dictionary dic) throws SMatchException {
log.info("Creating adjective synonyms array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.ADJECTIVE);
while (it.hasNext()) {
count++;
if (0 == count % 1000) {
log.debug("adjective synonyms: " + count);
}
Synset source = it.next();
long sourceOffset = source.getOffset();
List<Pointer> pointers = source.getPointers(PointerType.SIMILAR_TO);
for (Pointer ptr : pointers) {
long targetOffset = ptr.getTargetOffset();
long key;
if (targetOffset > sourceOffset) {
key = (targetOffset << 32) + sourceOffset;
} else {
key = (sourceOffset << 32) + targetOffset;
}
keys.add(key);
}
}
log.info("Adjective synonyms: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例12: findAdverbAntonyms
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findAdverbAntonyms(Dictionary dic) throws SMatchException {
log.info("Creating adverb antonyms array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.ADVERB);
while (it.hasNext()) {
count++;
if (0 == count % 1000) {
log.debug("adverb antonyms: " + count);
}
Synset source = it.next();
long sourceOffset = source.getOffset();
List<Pointer> pointers = source.getPointers(PointerType.ANTONYM);
for (Pointer ptr : pointers) {
long targetOffset = ptr.getTargetOffset();
long key;
if (targetOffset > sourceOffset) {
key = (targetOffset << 32) + sourceOffset;
} else {
key = (sourceOffset << 32) + targetOffset;
}
keys.add(key);
}
}
log.info("Adverbs antonyms: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例13: findNounHypernyms
import net.sf.extjwnl.JWNLException; //导入方法依赖的package包/类
private static Set<Long> findNounHypernyms(Dictionary dic) throws SMatchException {
log.info("Creating noun hypernyms array...");
try {
Set<Long> keys = new HashSet<>();
int count = 0;
Iterator<Synset> it = dic.getSynsetIterator(POS.NOUN);
while (it.hasNext()) {
count++;
if (0 == count % 10000) {
log.debug("noun hypernyms: " + count);
}
Synset source = it.next();
long sourceOffset = source.getOffset();
traverseTreeMG(keys, PointerUtils.getHypernymTree(source), sourceOffset);
traverseTreeMG(keys, PointerUtils.getInheritedHolonyms(source), sourceOffset);
traverseTreeMG(keys, PointerUtils.getInheritedMemberHolonyms(source), sourceOffset);
traverseTreeMG(keys, PointerUtils.getInheritedPartHolonyms(source), sourceOffset);
traverseTreeMG(keys, PointerUtils.getInheritedSubstanceHolonyms(source), sourceOffset);
traverseListMG(keys, PointerUtils.getHolonyms(source), sourceOffset);
traverseListMG(keys, PointerUtils.getMemberHolonyms(source), sourceOffset);
traverseListMG(keys, PointerUtils.getPartHolonyms(source), sourceOffset);
traverseListMG(keys, PointerUtils.getSubstanceHolonyms(source), sourceOffset);
}
log.info("Noun hypernyms: " + keys.size());
return keys;
} catch (JWNLException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}