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


Java JWNLException类代码示例

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


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

示例1: getDerivedAdjective

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
/**
	 * Returns the derived adjective with the same word form for the most common sense of the given noun if exists.
	 *
	 * @param noun the noun
	 */
	public String getDerivedAdjective(String noun) {
		try {
			IndexWord nounIW = dict.lookupIndexWord(POS.NOUN, noun);

			List<Synset> senses = nounIW.getSenses();

			Synset mainSense = senses.get(0);

			List<Pointer> pointers = mainSense.getPointers(PointerType.DERIVATION);

			for (Pointer pointer : pointers) {
				Synset derivedSynset = pointer.getTargetSynset();
				if(derivedSynset.getPOS() == POS.ADJECTIVE) {
//					return derivedSynset.getWords().get(0).getLemma();
				}
				if(derivedSynset.getPOS() == POS.VERB) {
					System.out.println(derivedSynset);
				}
			}
		} catch (JWNLException e) {
			e.printStackTrace();
		}
		return null;
	}
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:30,代码来源:WordNetUtils.java

示例2: PropertyVerbalizer

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
public PropertyVerbalizer(IRIConverter uriConverter, Dictionary wordnetDictionary) {
	this.uriConverter = uriConverter;
	try {
		this.database = wordnetDictionary == null ? Dictionary.getDefaultResourceInstance() : wordnetDictionary;
	} catch (JWNLException e) {
		throw new RuntimeException("Failed to create WordNet instance.", e);
	}

	preposition = new Preposition();

	Properties props = new Properties();
	props.put("annotators", "tokenize, ssplit, pos, lemma, parse");
	props.put("ssplit.isOneSentence", "true");
	pipeline = new StanfordCoreNLPWrapper(new StanfordCoreNLP(props));
	// pipeline = new StanfordCoreNLPWrapper(new
	// StanfordCoreNLPClient(props, "titan.informatik.uni-leipzig.de",
	// 9000));
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:19,代码来源:PropertyVerbalizer.java

示例3: getDerivedAdjective

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
/**
 * Returns the derived adjective with the same word form for the most common
 * sense of the given noun if exists.
 *
 * @param noun
 *            the noun
 */
public String getDerivedAdjective(String noun) {
	try {
		IndexWord nounIW = dict.lookupIndexWord(POS.NOUN, noun);

		List<Synset> senses = nounIW.getSenses();

		Synset mainSense = senses.get(0);

		List<Pointer> pointers = mainSense.getPointers(PointerType.DERIVATION);

		for (Pointer pointer : pointers) {
			Synset derivedSynset = pointer.getTargetSynset();
			if (derivedSynset.getPOS() == POS.ADJECTIVE) {
				// return derivedSynset.getWords().get(0).getLemma();
			}
			if (derivedSynset.getPOS() == POS.VERB) {
				System.out.println(derivedSynset);
			}
		}
	} catch (JWNLException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:32,代码来源:WordNetUtils.java

示例4: getSynsetsOf

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
public Set<Synset> getSynsetsOf(String lemma, WordNetPartOfSpeech partOfSpeech)  throws WordNetException
{
	if (doNotProcessThisWord(lemma))
		return new LinkedHashSet<Synset>();
	else
	{
		try
		{
			IndexWord indexWord = extJwnlRealDictionary.lookupIndexWord(ExtJwnlUtils.getJwnlPartOfSpeec(partOfSpeech), lemma);
			return indexWordToSet(indexWord);
		}
		catch(JWNLException e)
		{
			throw new WordNetException("looking for word <"+lemma+"> with part of speech: "+partOfSpeech.toString()+" failed. See nested exception",e);
		}
	}
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:18,代码来源:ExtJwnlDictionary.java

示例5: testSetPointer

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testSetPointer() throws JWNLException {
    Synset hyponym = new Synset(dictionary, POS.NOUN, 1);
    hyponym.setGloss("hyponym");
    Synset hypernym = new Synset(dictionary, POS.NOUN, 2);
    hypernym.setGloss("hypernym");
    dictionary.edit();
    testObj.getPointers().add(new Pointer(PointerType.HYPERNYM, testObj, hypernym));
    testObj.getPointers().set(0, new Pointer(PointerType.HYPONYM, testObj, hyponym));
    Assert.assertEquals(1, testObj.getPointers().size());
    Assert.assertEquals(1, hyponym.getPointers().size());
    Assert.assertEquals(0, hypernym.getPointers().size());
    Assert.assertEquals(PointerType.HYPERNYM, hyponym.getPointers().get(0).getType());
    Assert.assertEquals(testObj, hyponym.getPointers().get(0).getTarget());

    Assert.assertEquals(1, testObj.getTargets().size());
    Assert.assertEquals(hyponym, testObj.getTargets().get(0));
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:19,代码来源:TestSynset.java

示例6: testReverse

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testReverse() throws JWNLException, CloneNotSupportedException {
    dictionary.edit();
    Synset s1 = dictionary.createSynset(POS.NOUN);
    Synset s2 = dictionary.createSynset(POS.NOUN);
    SymmetricRelationship r =
            new SymmetricRelationship(PointerType.HYPERNYM,
                    new PointerTargetNodeList(Arrays.asList(
                            new PointerTargetNode(s1),
                            new PointerTargetNode(s2)
                    )),
                    s1, s2);
    Relationship rev = r.reverse();

    Assert.assertEquals(2, rev.getSize());
    Assert.assertEquals(2, rev.getNodeList().size());
    Assert.assertEquals(PointerType.HYPONYM, rev.getNodeList().get(0).getType());
    Assert.assertEquals(PointerType.HYPONYM, rev.getNodeList().get(1).getType());
    Assert.assertEquals(s2, rev.getNodeList().get(0).getSynset());
    Assert.assertEquals(s1, rev.getNodeList().get(1).getSynset());
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:22,代码来源:TestSymmetricRelationship.java

示例7: isSourceSynonymTarget

import net.sf.extjwnl.JWNLException; //导入依赖的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;
}
 
开发者ID:s-match,项目名称:s-match-wordnet,代码行数:20,代码来源:WordNet.java

示例8: testIndexWordSubstringIterator

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testIndexWordSubstringIterator() throws IOException, JWNLException {
    dictionary.edit();

    createEntityWord(dictionary);
    createPEntityWord(dictionary);
    createEntityPEntityPointer(dictionary);
    createAbstractionWords(dictionary);

    Iterator<IndexWord> i = dictionary.getIndexWordIterator(POS.NOUN, "abstract");
    List<IndexWord> indexWords = new ArrayList<IndexWord>(2);
    List<String> lemmas = new ArrayList<String>(2);
    while (i.hasNext()) {
        indexWords.add(i.next());
        lemmas.add(indexWords.get(indexWords.size() - 1).getLemma());
    }
    Assert.assertEquals(2, indexWords.size());
    Assert.assertTrue(lemmas.contains(abstractionWords[0]));
    Assert.assertTrue(lemmas.contains(abstractionWords[1]));
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:21,代码来源:DictionaryEditTester.java

示例9: testConstructor2Lexical

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testConstructor2Lexical() throws JWNLException {
    dictionary.edit();
    Synset s = new Synset(dictionary, POS.NOUN, 1);
    Word sw = new Word(dictionary, s, "test");
    s.getWords().add(sw);

    Synset t = new Synset(dictionary, POS.ADJECTIVE, 2);
    Word tw = new Word(dictionary, t, "rest");
    t.getWords().add(tw);

    Pointer p = new Pointer(PointerType.ANTONYM, sw, tw);
    Assert.assertNotNull(p);
    Assert.assertEquals(sw, p.getSource());
    Assert.assertEquals(tw, p.getTarget());
    Assert.assertEquals(t, p.getTargetSynset());
    Assert.assertEquals(POS.ADJECTIVE, p.getTargetPOS());
    Assert.assertEquals(2, p.getTargetOffset());
    Assert.assertEquals(PointerType.ANTONYM, p.getType());
    Assert.assertTrue(p.isLexical());
    Assert.assertFalse(p.isSemantic());
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:23,代码来源:TestPointer.java

示例10: testSynsetRemove

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testSynsetRemove() throws IOException, JWNLException {
    dictionary.edit();

    createEntityWord(dictionary);
    createPEntityWord(dictionary);
    createEntityPEntityPointer(dictionary);
    checkIterators(dictionary);
    createAbstractionWords(dictionary);

    IndexWord iwAbstraction = dictionary.getIndexWord(POS.NOUN, abstractionWords[0]);
    Synset synAbstraction = iwAbstraction.getSenses().get(0);
    dictionary.removeSynset(synAbstraction);
    testSynsetIterator(dictionary);

    IndexWord iwEntity = dictionary.getIndexWord(POS.NOUN, entityLemma);
    Synset synEntity = iwEntity.getSenses().get(0);
    Assert.assertEquals(1, synEntity.getPointers().size());

    IndexWord[] iwAbstractions = new IndexWord[2];
    for (int i = 0; i < abstractionWords.length; i++) {
        iwAbstractions[i] = dictionary.getIndexWord(POS.NOUN, abstractionWords[i]);
        Assert.assertNull(iwAbstractions[i]);
    }
    testIndexWordIterator(dictionary);
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:27,代码来源:DictionaryEditTester.java

示例11: testBrightAdv

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testBrightAdv() throws JWNLException {
    IndexWord iw = dictionary.getIndexWord(POS.ADVERB, "bright");
    Assert.assertNotNull("IndexWord loaded", iw);
    Synset synset = null;
    for (Synset s : iw.getSenses()) {
        if (advOffsets.contains(s.getOffset())) {
            synset = s;
            break;
        }
    }

    Assert.assertNotNull("Synset search", synset);
    Assert.assertEquals("Pointer testing", 2, synset.getPointers().size());
    for (Word w : synset.getWords()) {
        Assert.assertTrue("Synset word loading: " + w.getLemma(), advLemmas.contains(w.getLemma()));
    }
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:19,代码来源:DictionaryReadTester.java

示例12: importWordnet

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
public static void importWordnet(String propertyFile, String tablesScript, String driverClass, String connectionURL, String username, String password) throws IOException, JWNLException, SQLException {
    Dictionary dictionary = Dictionary.getInstance(new FileInputStream(propertyFile));
    Connection conn = null;

    try {
        ConnectionManager mgr = new ConnectionManager(dictionary, driverClass, connectionURL, username, password);
        conn = mgr.getConnection();
        conn.setReadOnly(false);
        DictionaryToDatabase d2d = new DictionaryToDatabase(dictionary, conn);
        d2d.createTables(tablesScript);
        d2d.insertData();
    } finally {
        if (null != conn) {
            conn.close();
        }
    }
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:18,代码来源:DictionaryToDatabase.java

示例13: testIndexWordRemoveRecreate

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
@Test
public void testIndexWordRemoveRecreate() throws IOException, JWNLException {
    dictionary.edit();

    createEntityWord(dictionary);
    createPEntityWord(dictionary);
    createEntityPEntityPointer(dictionary);
    createAbstractionWords(dictionary);
    testAbstractionWords(dictionary);

    IndexWord iwAbstraction = dictionary.getIndexWord(POS.NOUN, abstractionWords[1]);
    dictionary.removeIndexWord(iwAbstraction);

    saveAndReloadDictionary();

    iwAbstraction = dictionary.getIndexWord(POS.NOUN, abstractionWords[1]);
    Assert.assertNull(iwAbstraction);
    iwAbstraction = dictionary.getIndexWord(POS.NOUN, abstractionWords[0]);
    Synset synAbstraction = iwAbstraction.getSenses().get(0);
    Assert.assertEquals(1, synAbstraction.getWords().size());
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:22,代码来源:DictionaryEditTester.java

示例14: cacheUseCounts

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
private void cacheUseCounts() throws JWNLException {
    if (log.isDebugEnabled()) {
        log.debug(dictionary.getMessages().resolveMessage("PRINCETON_INFO_018"));
    }

    PointedCharSequence line = revCntList.readLine(0);
    while (null != line && 0 != line.length()) {
        //sense_key  sense_number  tag_cnt
        CharSequenceParser p = new CharSequenceParser(line);
        String senseKey = p.nextToken(); // sense_key
        p.skipToken(); // skip sense_number
        Integer useCnt = p.nextInt(); // tag_cnt
        useCountCache.put(senseKey, useCnt);
        line = revCntList.readLine(line.getLastBytePosition() + 1);
    }
    if (log.isDebugEnabled()) {
        log.debug(dictionary.getMessages().resolveMessage("PRINCETON_INFO_019"));
    }
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:20,代码来源:FileManagerImpl.java

示例15: execute

import net.sf.extjwnl.JWNLException; //导入依赖的package包/类
public boolean execute(POS pos, String derivation, BaseFormSet forms) throws JWNLException {
    String[][] suffixArray = suffixMap.get(pos);
    if (suffixArray == null) {
        return false;
    }

    boolean addedBaseForm = false;
    for (String[] aSuffixArray : suffixArray) {
        if (derivation.endsWith(aSuffixArray[0])) {
            String stem = derivation.substring(0, derivation.length() - aSuffixArray[0].length()) + aSuffixArray[1];
            if (delegate(pos, stem, forms, OPERATIONS)) {
                addedBaseForm = true;
            }
        }
    }
    return addedBaseForm;
}
 
开发者ID:extjwnl,项目名称:extjwnl,代码行数:18,代码来源:DetachSuffixesOperation.java


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