• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RAMDictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: initialize

import edu.mit.jwi.RAMDictionary; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
        throws ResourceInitializationException {
    super.initialize(context);
    try {
        if (dictFile == null) // use default
            dictFile = CommonAnnotatorsHelper.COMMON_ANNOTATORS_ROOT
                    + "src/main/resources/wordnet-3.1/dict";
        dict = new RAMDictionary(new File(dictFile),
                ILoadPolicy.BACKGROUND_LOAD);
        dict.open();
        stemmer = new WordnetStemmer(dict);
    } catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:17,代码来源:WordnetAnnotator.java


示例2: loadDictionary

import edu.mit.jwi.RAMDictionary; //导入依赖的package包/类
private void loadDictionary() {
    try {
        dictionary = new RAMDictionary(new File("wordnet/dict"), ILoadPolicy.NO_LOAD);
        dictionary.open();
        dictionary.load();

        logger.info("wordnet dictionary loaded.");

    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:bpark,项目名称:chlorophytum-semantics,代码行数:13,代码来源:DictionaryCache.java


示例3: WordNet

import edu.mit.jwi.RAMDictionary; //导入依赖的package包/类
public WordNet() throws Exception {
	url = new URL("file", null, wordNetDir);
	dict = new RAMDictionary(url, ILoadPolicy.NO_LOAD);
	dict.open();
	System.out.println("Loading wordNet...");
	dict.load(true); // load dictionary into memory
	System.out.println("WordNet loaded.");
	
	stemmer = new WordnetStemmer(dict);
}
 
开发者ID:DukeNLIDB,项目名称:NLIDB,代码行数:11,代码来源:WordNet.java


示例4: createDefaultEObjectMatcher

import edu.mit.jwi.RAMDictionary; //导入依赖的package包/类
public static IEObjectMatcher createDefaultEObjectMatcher(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry) {
	try {
		switch (useIDs) {
		case NEVER:
			String wordnetDictionaryPath = "WordNet-3.1" + File.separator + "dict"; 
			URIFactory uriFactory = URIFactoryMemory.getSingleton();
			URI wordnetGraphURI = uriFactory.getURI("http://graph/wordnet/"); 
			G wordnetGraph = new GraphMemory(wordnetGraphURI);
			GraphLoader_Wordnet wordnetGraphLoader = new GraphLoader_Wordnet();
			GDataConf dataNoun = new GDataConf(GFormat.WORDNET_DATA, wordnetDictionaryPath + File.separator + "data.noun");
			GDataConf dataVerb = new GDataConf(GFormat.WORDNET_DATA, wordnetDictionaryPath + File.separator + "data.verb");
			wordnetGraphLoader.populate(dataNoun, wordnetGraph);
			wordnetGraphLoader.populate(dataVerb, wordnetGraph);
			GAction addRoot = new GAction(GActionType.REROOTING);
			GraphActionExecutor.applyAction(addRoot, wordnetGraph); 
			String indexNoun = wordnetDictionaryPath + File.separator + "index.noun"; 
			String indexVerb = wordnetDictionaryPath + File.separator + "index.verb"; 
			IndexerWordNetBasic wordnetNounIndexer = new IndexerWordNetBasic(uriFactory, wordnetGraph, indexNoun);
			IndexerWordNetBasic wordnetVerbIndexer = new IndexerWordNetBasic(uriFactory, wordnetGraph, indexVerb);
			SM_Engine similarityComparationEngine = new SM_Engine(wordnetGraph);
			ICconf informationContentConfiguration = new IC_Conf_Topo(SMConstants.FLAG_ICI_SECO_2004);
			SMconf similarityMeasureConfiguration = new SMconf(SMConstants.FLAG_SIM_PAIRWISE_DAG_NODE_LIN_1998);
			//SMconf similarityMeasureConfiguration = new SMconf(SMConstants.FLAG_SIM_PAIRWISE_DAG_NODE_JIANG_CONRATH_1997_NORM);
			similarityMeasureConfiguration.setICconf(informationContentConfiguration);
			RAMDictionary wordnetDictionary = new RAMDictionary(new URL("file", null, wordnetDictionaryPath), ILoadPolicy.IMMEDIATE_LOAD);
			wordnetDictionary.setLoadPolicy(ILoadPolicy.NO_LOAD);
			WordnetStemmer wordnetStemmer = new WordnetStemmer(wordnetDictionary);
			MaxentTagger maxentTagger = new MaxentTagger("tagger" + File.separator + "english" + File.separator + "english-left3words-distsim.tagger");
			return new ProximityEObjectMatcher(new SemanticDistanceFunction(similarityComparationEngine, similarityMeasureConfiguration, wordnetNounIndexer, wordnetVerbIndexer, maxentTagger, wordnetStemmer, wordnetDictionary));
		case ONLY:
			return new IdentifierEObjectMatcher();
		case WHEN_AVAILABLE:
		default:
			String wordnetDictionaryPath_Beta = "WordNet-3.1" + File.separator + "dict"; 
			URIFactory uriFactory_Beta = URIFactoryMemory.getSingleton();
			URI wordnetGraphURI_Beta = uriFactory_Beta.getURI("http://graph/wordnet/"); 
			G wordnetGraph_Beta = new GraphMemory(wordnetGraphURI_Beta);
			GraphLoader_Wordnet wordnetGraphLoader_Beta = new GraphLoader_Wordnet();
			GDataConf dataNoun_Beta = new GDataConf(GFormat.WORDNET_DATA, wordnetDictionaryPath_Beta + File.separator + "data.noun");
			GDataConf dataVerb_Beta = new GDataConf(GFormat.WORDNET_DATA, wordnetDictionaryPath_Beta + File.separator + "data.verb");
			wordnetGraphLoader_Beta.populate(dataNoun_Beta, wordnetGraph_Beta);
			wordnetGraphLoader_Beta.populate(dataVerb_Beta, wordnetGraph_Beta);
			GAction addRoot_Beta = new GAction(GActionType.REROOTING);
			GraphActionExecutor.applyAction(addRoot_Beta, wordnetGraph_Beta); 
			String indexNoun_Beta = wordnetDictionaryPath_Beta + File.separator + "index.noun"; 
			String indexVerb_Beta = wordnetDictionaryPath_Beta + File.separator + "index.verb"; 
			IndexerWordNetBasic wordnetNounIndexer_Beta = new IndexerWordNetBasic(uriFactory_Beta, wordnetGraph_Beta, indexNoun_Beta);
			IndexerWordNetBasic wordnetVerbIndexer_Beta = new IndexerWordNetBasic(uriFactory_Beta, wordnetGraph_Beta, indexVerb_Beta);
			SM_Engine similarityComparationEngine_Beta = new SM_Engine(wordnetGraph_Beta);
			ICconf informationContentConfiguration_Beta = new IC_Conf_Topo(SMConstants.FLAG_ICI_SECO_2004);
			SMconf similarityMeasureConfiguration_Beta = new SMconf(SMConstants.FLAG_SIM_PAIRWISE_DAG_NODE_LIN_1998);
			similarityMeasureConfiguration_Beta.setICconf(informationContentConfiguration_Beta);
			RAMDictionary wordnetDictionary_Beta = new RAMDictionary(new URL("file", null, wordnetDictionaryPath_Beta), ILoadPolicy.IMMEDIATE_LOAD);
			wordnetDictionary_Beta.setLoadPolicy(ILoadPolicy.NO_LOAD);
			WordnetStemmer wordnetStemmer_Beta = new WordnetStemmer(wordnetDictionary_Beta);
			MaxentTagger maxentTagger_Beta = new MaxentTagger("tagger" + File.separator + "english" + File.separator + "english-left3words-distsim.tagger");
			return new IdentifierEObjectMatcher(
					new ProximityEObjectMatcher(
							new SemanticDistanceFunction(similarityComparationEngine_Beta, similarityMeasureConfiguration_Beta, wordnetNounIndexer_Beta, wordnetVerbIndexer_Beta, maxentTagger_Beta, wordnetStemmer_Beta, wordnetDictionary_Beta)));

		}
	} catch (MalformedURLException | SLIB_Exception e) {
		e.printStackTrace();
		return new IdentifierEObjectMatcher();
	}
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:67,代码来源:SemanticMatchEngine.java


示例5: createDefaultEObjectMatcher

import edu.mit.jwi.RAMDictionary; //导入依赖的package包/类
public static IEObjectMatcher createDefaultEObjectMatcher(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry){
	try{
		if(useIDs.equals(UseIdentifiers.ONLY)){
			/** Default Match Engine behaviour in case the user wants to consider them only */
			return new IdentifierEObjectMatcher();
		} else {
			/* Wordnet Dictionary Folder Path */
			String wordnetDictionaryPath = "WordNet-3.1" + File.separator + "dict"; 
			if(SemanticEMFCompareRCPPlugin.getDefault() != null) {
				URL wordnetDictionaryURL = FileLocator.resolve(FileLocator.find(SemanticEMFCompareRCPPlugin.getDefault().getBundle(), new Path("WordNet-3.1" + File.separator + "dict"), null));
				String wordnetDictionaryURLExternalForm = wordnetDictionaryURL.toExternalForm();
				wordnetDictionaryPath = wordnetDictionaryURLExternalForm.substring(wordnetDictionaryURLExternalForm.lastIndexOf(".." + File.separator) + 2);
			}
			System.out.println(wordnetDictionaryPath);
			/* Wordnet Graph - Initialization (SMLib) */
			URIFactory uriFactory = URIFactoryMemory.getSingleton();
			URI wordnetGraphURI = uriFactory.getURI("http://graph/wordnet");
			G wordnetGraph = new GraphMemory(wordnetGraphURI);
			/* Wordnet Graph - Population (SMLib) */
			GraphLoader_Wordnet wordnetGraphLoader = new GraphLoader_Wordnet();
			GDataConf dataNoun = new GDataConf(GFormat.WORDNET_DATA, wordnetDictionaryPath + File.separator + "data.noun");
			wordnetGraphLoader.populate(dataNoun, wordnetGraph);
			GDataConf dataVerb = new GDataConf(GFormat.WORDNET_DATA, wordnetDictionaryPath + File.separator + "data.verb");
			wordnetGraphLoader.populate(dataVerb, wordnetGraph);
			/* Wordnet Graph - Orientation (this is made in order to allow comparations among terms which do not share any synset)  (SMLib) */
			GAction addRoot = new GAction(GActionType.REROOTING);
			GraphActionExecutor.applyAction(addRoot, wordnetGraph);
			/* Wordnet Graph - Content Indexing  (SMLib) */
			String indexNoun = wordnetDictionaryPath + File.separator + "index.noun"; 
			IndexerWordNetBasic wordnetNounIndexer = new IndexerWordNetBasic(uriFactory, wordnetGraph, indexNoun);
			String indexVerb = wordnetDictionaryPath + File.separator + "index.verb"; 
			IndexerWordNetBasic wordnetVerbIndexer = new IndexerWordNetBasic(uriFactory, wordnetGraph, indexVerb);
			/* Wordnet Graph - Comparation Engines  (SMLib) */
			SM_Engine similarityComparationEngine = new SM_Engine(wordnetGraph);
			ICconf informationContentConfiguration = new IC_Conf_Topo(SMConstants.FLAG_ICI_SECO_2004);
			SMconf similarityMeasureConfiguration = new SMconf(SMConstants.FLAG_SIM_PAIRWISE_DAG_NODE_LIN_1998);
			similarityMeasureConfiguration.setICconf(informationContentConfiguration);
			/* Wordnet RAM Dictionary (JWI, POS Tagging, Token Stemming) */
			RAMDictionary wordnetDictionary = new RAMDictionary(new URL("file", null, wordnetDictionaryPath), ILoadPolicy.IMMEDIATE_LOAD);
			//CachingDictionary wordnetDictionary = new CachingDictionary();
			wordnetDictionary.setLoadPolicy(ILoadPolicy.NO_LOAD);
			/* Wordnet Stemmer (Token Stemming) */
			WordnetStemmer wordnetStemmer = new WordnetStemmer(wordnetDictionary);
			/* Maxent Tagger (POS Tagging) */
			String maxentTaggerPath = "tagger" + File.separator + "english" + File.separator + "english-left3words-distsim.tagger"; 
			if(SemanticEMFCompareRCPPlugin.getDefault() != null){
				URL maxentTaggerURL = FileLocator.resolve(FileLocator.find(SemanticEMFCompareRCPPlugin.getDefault().getBundle(), new Path("tagger" + File.separator + "english" + File.separator + "english-left3words-distsim.tagger"), null));
				String maxentTaggerURLExternalForm = maxentTaggerURL.toExternalForm();
				maxentTaggerPath = maxentTaggerURLExternalForm.substring(maxentTaggerURLExternalForm.lastIndexOf(".." + File.separator) + 2);
			}
			MaxentTagger maxentTagger = new MaxentTagger(maxentTaggerPath);
			/** Semantic Match Engine behaviour in case the user does not want to consider IDs */
			if(useIDs.equals(UseIdentifiers.NEVER)){
				return new ProximityEObjectMatcher(new SemanticDistanceFunction(similarityComparationEngine, similarityMeasureConfiguration, wordnetNounIndexer, wordnetVerbIndexer, maxentTagger, wordnetStemmer, wordnetDictionary));
			} else {
			/** Default Match Engine with Semantic Fallback in case the user wants to use IDs if possible */
				return new IdentifierEObjectMatcher(
						new ProximityEObjectMatcher(
								new SemanticDistanceFunction(similarityComparationEngine, similarityMeasureConfiguration, wordnetNounIndexer, wordnetVerbIndexer, maxentTagger, wordnetStemmer, wordnetDictionary))); 
			}
		}
	} catch(MalformedURLException | SLIB_Exception e){
		e.printStackTrace();
		return new IdentifierEObjectMatcher();
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
		return new IdentifierEObjectMatcher();
	} 
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:71,代码来源:SemanticMatchEngine.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PermissionUtils类代码示例发布时间:2022-05-22
下一篇:
Java EaseUser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap