本文整理汇总了Java中net.sf.extjwnl.dictionary.Dictionary类的典型用法代码示例。如果您正苦于以下问题:Java Dictionary类的具体用法?Java Dictionary怎么用?Java Dictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dictionary类属于net.sf.extjwnl.dictionary包,在下文中一共展示了Dictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TripleConverterPortuguese
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
public TripleConverterPortuguese(QueryExecutionFactory qef, PropertyVerbalizerPortuguese propertyVerbalizer,
IRIConverter uriConverter, String cacheDirectory, Dictionary wordnetDirectory, Lexicon lexicon) {
if (uriConverter == null) {
uriConverter = new DefaultIRIConverterPortuguese(qef, cacheDirectory);
}
this.uriConverter = uriConverter;
if (propertyVerbalizer == null) {
propertyVerbalizer = new PropertyVerbalizerPortuguese(uriConverter, wordnetDirectory);
}
pp = propertyVerbalizer;
if (lexicon == null) {
lexicon = new XMLLexicon();
}
nlgFactory = new NLGFactory(lexicon);
realiser = new Realiser();
literalConverter = new LiteralConverterPortuguese(uriConverter);
literalConverter.setEncapsulateStringLiterals(encapsulateStringLiterals);
reasoner = new SPARQLReasoner(qef);
genderDetector = new DictionaryBasedGenderDetector();
}
示例2: PropertyVerbalizer
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的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));
}
示例3: TripleConverter
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
public TripleConverter(QueryExecutionFactory qef, PropertyVerbalizer propertyVerbalizer, IRIConverter uriConverter,
String cacheDirectory, Dictionary wordnetDirectory, Lexicon lexicon) {
if (uriConverter == null) {
uriConverter = new DefaultIRIConverter(qef, cacheDirectory);
}
this.uriConverter = uriConverter;
if (propertyVerbalizer == null) {
propertyVerbalizer = new PropertyVerbalizer(uriConverter, wordnetDirectory);
}
pp = propertyVerbalizer;
if (lexicon == null) {
lexicon = Lexicon.getDefaultLexicon();
}
nlgFactory = new NLGFactory(lexicon);
realiser = new Realiser(lexicon);
literalConverter = new LiteralConverter(uriConverter);
literalConverter.setEncapsulateStringLiterals(encapsulateStringLiterals);
reasoner = new SPARQLReasoner(qef);
genderDetector = new DictionaryBasedGenderDetector();
}
示例4: getDictionary
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
public static Dictionary getDictionary(String jwnlPropertiesPath) throws SMatchException {
try {
if (null != jwnlPropertiesPath) {
log.info("Initializing extJWNL (" + jwnlPropertiesPath + ")");
InputStream is = MiscUtils.getInputStream(jwnlPropertiesPath);
try {
return Dictionary.getInstance(is);
} finally {
if (null != is) {
is.close();
}
}
} else {
log.info("Initializing extJWNL (default resource instance)");
return Dictionary.getDefaultResourceInstance();
}
} catch (JWNLException | DISIException | IOException e) {
throw new SMatchException(e.getClass().getSimpleName() + ": " + e.getMessage(), e);
}
}
示例5: createWordNetCaches
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
* Create caches of WordNet to speed up matching.
*
* @param jwnlPropertiesPath extJWNL properties file path
* @param adjectiveSynonyms adjective synonyms file path
* @param adjectiveAntonyms adjective antonyms file path
* @param nounHypernyms noun hypernyms file path
* @param nounAntonyms noun antonyms file path
* @param adverbAntonyms adverb antonyms file path
* @param verbHypernyms verb hypernyms file path
* @param nominalizations nominalizations file path
* @throws SMatchException SMatchException
*/
public static void createWordNetCaches(String jwnlPropertiesPath,
String adjectiveSynonyms,
String adjectiveAntonyms,
String nounHypernyms,
String nounAntonyms,
String adverbAntonyms,
String verbHypernyms,
String nominalizations
) throws SMatchException {
Dictionary dic = WordNet.getDictionary(jwnlPropertiesPath);
log.info("Creating WordNet caches...");
convertAndWrite(findNominalizations(dic), nominalizations);
convertAndWrite(findAdjectiveSynonyms(dic), adjectiveSynonyms);
convertAndWrite(findAdverbAntonyms(dic), adverbAntonyms);
convertAndWrite(findAdjectiveAntonyms(dic), adjectiveAntonyms);
convertAndWrite(findNounAntonyms(dic), nounAntonyms);
convertAndWrite(findNounHypernyms(dic), nounHypernyms);
convertAndWrite(findVerbHypernyms(dic), verbHypernyms);
log.info("Created WordNet caches");
}
示例6: findAdjectiveAntonyms
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的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);
}
}
示例7: findNounAntonyms
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的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);
}
}
示例8: findVerbHypernyms
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的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);
}
}
示例9: execute
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
* Execute the task of counting dictionary references
*
* @throws JWNLException
*/
public void execute() throws JWNLException {
IWiktionaryEdition wkt = JWKTL.openEdition(dumpFile);
Dictionary d = Constants.getDictionary();
// Do Noun Calculations
doCalculationsForPOS(wkt, d, POS.NOUN);
// Do Verb Calculations
doCalculationsForPOS(wkt, d, POS.VERB);
// Do Adjective Calculations
doCalculationsForPOS(wkt, d, POS.ADJECTIVE);
// Do Adverb Calculations
doCalculationsForPOS(wkt, d, POS.ADVERB);
// Free up some resources
wkt.close();
}
示例10: main
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, JWNLException, CloneNotSupportedException {
Dictionary dictionary = null;
if (args.length != 1) {
dictionary = Dictionary.getDefaultResourceInstance();
} else {
if (HELP_KEYS.contains(args[0])) {
System.out.println(USAGE);
} else {
FileInputStream inputStream = new FileInputStream(args[0]);
dictionary = Dictionary.getInstance(inputStream);
}
}
if (null != dictionary) {
new Examples(dictionary).go();
}
}
示例11: importWordnet
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的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();
}
}
}
示例12: removeAll
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
@Override
public boolean removeAll(Collection<?> c) {
loadAllSynsets();
if (null != dictionary && dictionary.isEditable()) {
Dictionary d = dictionary;
List<Synset> copy = new ArrayList<Synset>(this);
boolean result = super.removeAll(c);
if (result) {
for (Object object : c) {
if (object instanceof Synset) {
Synset synset = (Synset) object;
if (copy.contains(synset)) {
removeWordsFromSynset(synset, lemma);
}
}
}
checkIfWeReEmptyAndRemoveIndexWord(d);
}
return result;
} else {
return super.removeAll(c);
}
}
示例13: retainAll
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
@Override
public boolean retainAll(Collection<?> c) {
loadAllSynsets();
if (null != dictionary && dictionary.isEditable()) {
Dictionary d = dictionary;
List<Synset> copy = new ArrayList<Synset>(this);
boolean result = super.retainAll(c);
if (result) {
for (Synset synset : copy) {
if (!c.contains(synset)) {
removeWordsFromSynset(synset, lemma);
}
}
checkIfWeReEmptyAndRemoveIndexWord(d);
}
return result;
} else {
return super.retainAll(c);
}
}
示例14: IndexWord
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
protected IndexWord(Dictionary dictionary, String lemma, POS pos) throws JWNLException {
this.dictionary = dictionary;
if (null == lemma) {
if (null != dictionary) {
throw new IllegalArgumentException(dictionary.getMessages().resolveMessage("DICTIONARY_EXCEPTION_046"));
} else {
throw new IllegalArgumentException("Lemma must be not null and not empty");
}
}
this.lemma = lemma.toLowerCase();
if (null == pos) {
if (null != dictionary) {
throw new IllegalArgumentException(dictionary.getMessages().resolveMessage("DICTIONARY_EXCEPTION_041"));
} else {
throw new IllegalArgumentException("Pos must be not null");
}
}
this.pos = pos;
if (null != dictionary && dictionary.isEditable()) {
dictionary.addElement(this);
}
}
示例15: BaseFormsDictionary
import net.sf.extjwnl.dictionary.Dictionary; //导入依赖的package包/类
public BaseFormsDictionary(BaseformOverrideDictionary overrides) throws Exception {
BaseformOverrides = overrides;
String propsFile = ConfigurationManager.getConfiguration().getString("WordnetPropertiesFile");
InputStream stream = getClass().getResourceAsStream(propsFile);
wnDict = Dictionary.getInstance(stream);
bfDict = new HashMap<String,CSList<String>>();
supportedPartsOfSpeech = new CSList<String>(new String[]{"noun","verb","adjective","adverb"}); // JWNL 1.3 and 1.4 only support these POSes
}