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

Java IPointer类代码示例

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

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



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

示例1: fillList

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
Set<String> fillList(Pointer ptype,Map<IPointer, List<IWordID>> wordMap,Map<IPointer, List<ISynsetID>> synMap){
	Set<String> ts;
	List<IWordID> tw;
	List<ISynsetID> tsy;
	ts  = new TreeSet<String>();
	tw = wordMap.get(ptype);
	if(tw!=null){
		for(IWordID wid:tw){
			String tempString = wid.getLemma();
			if(tempString!=null)ts.add(tempString);
		}
	}
	tsy = synMap.get(ptype);
	if(tsy!=null){
		for(ISynsetID sid:tsy){
			List<IWord> t = dict.getSynset(sid).getWords();
			if(t!=null)
				for(IWord w:t){
					ts.add(w.getLemma());
				}
		}
	}
	if(!ts.isEmpty())return ts;
	return null;
}
 
开发者ID:MusicCraftor,项目名称:WordNet-Explorer,代码行数:26,代码来源:WordDic.java


示例2: getRelatedSynsets

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
private void getRelatedSynsets(Map<BabelSynset, RelatedSynset> map, int distance) throws IOException {
    List<BabelSynset> listKey = new ArrayList<>(map.keySet());
    for (BabelSynset synset : listKey) {
        RelatedSynset get = map.get(synset);
        if (!get.isVisited()) {
            get.setVisited(true);
            Map<IPointer, List<BabelSynset>> relatedMap = synset.getRelatedMap();
            Iterator<IPointer> itRel = relatedMap.keySet().iterator();
            while (itRel.hasNext()) {
                IPointer pointer = itRel.next();
                if (!pointer.getName().equalsIgnoreCase("antonym")) {
                    List<BabelSynset> list = relatedMap.get(pointer);
                    for (BabelSynset relSynset : list) {
                        RelatedSynset rs = map.get(relSynset);
                        if (rs == null) {
                            map.put(relSynset, new RelatedSynset(relSynset, distance));
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:24,代码来源:RevisedLesk.java


示例3: getRelatedMap

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
/**
 * Collects <i>all</i> {@link BabelSynset}s related to <b>this</b>
 * {@link BabelSynset}.
 * 
 * @return the {@link BabelSynset}s related to <b>this</b>
 *         {@link BabelSynset}
 * @throws IOException
 */
public Map<IPointer, List<BabelSynset>> getRelatedMap() throws IOException
{
	if (relatedMap == null)
	{
		// init the relation map
		BabelNet bn = BabelNet.getInstance();
		relatedMap = new HashMap<IPointer, List<BabelSynset>>();
		List<BabelNetGraphEdge> edges = bn.getSuccessorEdges(getId());
		for (BabelNetGraphEdge e : edges)
		{
			IPointer relation = e.getPointer();
			List<BabelSynset> synsetsForRelation = relatedMap.get(relation);
			if (synsetsForRelation == null)
			{
				synsetsForRelation = new ArrayList<BabelSynset>();
				relatedMap.put(relation, synsetsForRelation);
			}
			BabelSynset synset = bn.getSynsetFromId(e.getTarget());
			synsetsForRelation.add(synset);
		}
	}
	return relatedMap;
}
 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:32,代码来源:BabelSynset.java


示例4: getRelatedWords

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public Map<MappedString, Float> getRelatedWords(ISynset s, int depth, int maxDepth, IPointer relationType, boolean assignDepthPenalty, List<TraceElement> trace) {
		if (depth == maxDepth) {
			return Collections.emptyMap();
		}
		float scoreInThisDepth = 1.0f;
		if (assignDepthPenalty) {
			scoreInThisDepth -= (float)depth / maxDepth;
		}
		Map<MappedString, Float> res = new HashMap<MappedString, Float>();
//		Map foo = word.getRelatedMap();
		List<ISynsetID> sIDs = s.getRelatedSynsets(relationType);
		for (ISynsetID sID : sIDs) {
			ISynset hS;
			synchronized (dict) {
				hS = dict.getSynset(sID);
			}
			List<TraceElement> _trace = new LinkedList<TraceElement>(trace);
			_trace.add(new TraceElement(hS.getGloss() + " (" + relationType.getName() + ")", ""));
			for (IWord h : hS.getWords()) {
				List<TraceElement> __trace = new LinkedList<TraceElement>(trace);
				__trace.add(new TraceElement(h.getLemma() + " (" + relationType.getName() + ")", getWordNetUrl(h)));
				addSynonym(res, h.getLemma(), __trace, scoreInThisDepth);
			}
			addSynonyms(res, getRelatedWords(hS, depth + 1, maxDepth, relationType, assignDepthPenalty, _trace));
		}
		return res;
	}
 
开发者ID:johannessimon,项目名称:pal,代码行数:28,代码来源:WordNetConnector.java


示例5: www12Test

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
/**
 * The snippet contained in our WWW-12 demo paper
 * 
 */
public static void www12Test() throws IOException
{
	BabelNet bn = BabelNet.getInstance();
	System.out.println("SYNSETS WITH English word: \"bank\"");
	List<BabelSynset> synsets = bn.getSynsets(Language.EN, "bank");
	Collections.sort(synsets, new BabelSynsetComparator("bank"));
	for (BabelSynset synset : synsets)
	{
		System.out.print("  =>(" + synset.getId() + ") SOURCE: " + synset.getSynsetSource() +
						 "; TYPE: " + synset.getSynsetType() + 
						 "; WN SYNSET: " + synset.getWordNetOffsets() + ";\n" +
						 "  MAIN LEMMA: " + synset.getMainSense() + 
						 ";\n  IMAGES: " + synset.getImages() + 
						 ";\n  CATEGORIES: " + synset.getCategories() + 
						 ";\n  SENSES (German): { ");
		for (BabelSense sense : synset.getSenses(Language.DE))
			System.out.print(sense.toString()+" ");
		System.out.println("}\n  -----");
		Map<IPointer, List<BabelSynset>> relatedSynsets = synset.getRelatedMap(); 
		for (IPointer relationType : relatedSynsets.keySet())
		{
			List<BabelSynset> relationSynsets = relatedSynsets.get(relationType);
			for (BabelSynset relationSynset : relationSynsets)
			{
				System.out.println("    EDGE " + relationType.getSymbol() +
								   " " + relationSynset.getId() +
								   " " + relationSynset.toString(Language.EN));
			}
		}
		System.out.println("  -----");
	}
}
 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:37,代码来源:BabelNetDemo.java


示例6: KnowledgeGraphPathEdge

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public KnowledgeGraphPathEdge(String src, String target,
									String pointerSymbol, IPointer pointer,
									double weight)
{
	this.src = src;
	this.target = target;
	this.pointer =  pointer;
	this.pointerSymbol =  pointerSymbol;
	this.weight = weight;
}
 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:11,代码来源:KnowledgeGraphPathEdge.java


示例7: printDegree

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
/**
 * Prints information about the degree of a {@link KnowledgeGraph} with a
 * specific scorer
 * 
 * @param simpleGraph
 * @param kb
 */
public static void printDegree(KnowledgeGraph simpleGraph, KnowledgeBase kb)
{
	StringBuffer buffer = new StringBuffer();
	Collection<String> concepts = simpleGraph.getConceptsForSourceWords();
	DirectedGraph<String, WeightedLabeledEdge> graph = simpleGraph.getGraph();

	for (String concept : concepts)
	{
		double weightedSum = 0.0;
		int degree = graph.outDegreeOf(concept);
		Multimap<IPointer, ScoredItem<String>> related = kb.getRelatedConceptsMap(concept);

		buffer.append("\n    OFFSET = ").append(concept).append(" SENSE = ").append(kb.conceptToString(concept)).append("\n\n      OUTGOING EDGES\n");

		for (WeightedLabeledEdge edge : graph.outgoingEdgesOf(concept))
		{
			weightedSum += edge.getWeight();

			String src = graph.getEdgeSource(edge);
			String target = graph.getEdgeTarget(edge);

			buffer.append("\n      ").append(kb.conceptToString(src)).append(":").append(edge.getLabel()).append("[").append(edge.getWeight()).append("]:").append(kb.conceptToString(target));
		}
		buffer.append("\n    ==============================");
		buffer.append("\n    DEGREE: ").append(degree).append("/").append(related.size()).append("=").append(Strings.format((double) degree / (double) related.size()))
				.append(" -- WEIGHTED SUM: ").append(Strings.format(weightedSum)).append("/").append(related.size()).append("=")
				.append(Strings.format((double) weightedSum / (double) related.size()));
		buffer.append("\n    ==============================");
	}

	log.info(buffer);
}
 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:40,代码来源:KnowledgeGraphUtils.java


示例8: getTMap

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
private Map<String,Set<String>> getTMap(int nType,int nOrder,int n){
	if(nType>=wordIndexArray.length)return null;
	Map<String,Set<String>>ret = new HashMap<String, Set<String>>();
	IIndexWord iarray = wordIndexArray[nType];
	IWordID wordID = iarray.getWordIDs().get(nOrder);
	Map<IPointer, List<IWordID>> wordMap =  dict.getWord(wordID).getRelatedMap();
	Map<IPointer, List<ISynsetID>> synMap = dict.getSynset(wordID.getSynsetID()).getRelatedMap();
	Set<String> stemp;
	if((stemp = fillList(Pointer.ALSO_SEE,wordMap,synMap))!=null)ret.put(TALSO_SEE,stemp);
	if((stemp = fillList(Pointer.ANTONYM,wordMap,synMap))!=null)ret.put(TANTONYM,stemp);
	if((stemp = fillList(Pointer.ATTRIBUTE,wordMap,synMap))!=null)ret.put(TATTRIBUTE,stemp);
	if((stemp = fillList(Pointer.CAUSE,wordMap,synMap))!=null)ret.put(TCAUSE,stemp);
	if((stemp = fillList(Pointer.DERIVATIONALLY_RELATED,wordMap,synMap))!=null)ret.put(TDERIVATIONALLY_RELATED,stemp);
	if((stemp = fillList(Pointer.DERIVED_FROM_ADJ,wordMap,synMap))!=null)ret.put(TDERIVED_FROM_ADJ,stemp);
	if((stemp = fillList(Pointer.DOMAIN,wordMap,synMap))!=null)ret.put(TDOMAIN,stemp);
	if((stemp = fillList(Pointer.ENTAILMENT,wordMap,synMap))!=null)ret.put(TENTAILMENT,stemp);
	if((stemp = fillList(Pointer.HOLONYM_MEMBER,wordMap,synMap))!=null)ret.put(THOLONYM_MEMBER,stemp);
	if((stemp = fillList(Pointer.HOLONYM_PART,wordMap,synMap))!=null)ret.put(THOLONYM_PART,stemp);
	if((stemp = fillList(Pointer.HOLONYM_SUBSTANCE,wordMap,synMap))!=null)ret.put(THOLONYM_SUBSTANCE,stemp);
	if((stemp = fillList(Pointer.HYPERNYM,wordMap,synMap))!=null)ret.put(THYPERNYM,stemp);
	if((stemp = fillList(Pointer.HYPERNYM_INSTANCE,wordMap,synMap))!=null)ret.put(THYPERNYM_INSTANCE,stemp);
	if((stemp = fillList(Pointer.HYPONYM,wordMap,synMap))!=null)ret.put(THYPONYM,stemp);
	if((stemp = fillList(Pointer.HYPONYM_INSTANCE,wordMap,synMap))!=null)ret.put(THYPONYM_INSTANCE,stemp);
	if((stemp = fillList(Pointer.MEMBER,wordMap,synMap))!=null)ret.put(TMEMBER,stemp);
	if((stemp = fillList(Pointer.MERONYM_MEMBER,wordMap,synMap))!=null)ret.put(TMERONYM_MEMBER,stemp);
	if((stemp = fillList(Pointer.MERONYM_PART,wordMap,synMap))!=null)ret.put(TMERONYM_PART,stemp);
	if((stemp = fillList(Pointer.MERONYM_SUBSTANCE,wordMap,synMap))!=null)ret.put(TMERONYM_SUBSTANCE,stemp);
	if((stemp = fillList(Pointer.PARTICIPLE,wordMap,synMap))!=null)ret.put(TPARTICIPLE,stemp);
	if((stemp = fillList(Pointer.PERTAINYM,wordMap,synMap))!=null)ret.put(TPERTAINYM,stemp);
	if((stemp = fillList(Pointer.REGION,wordMap,synMap))!=null)ret.put(TREGION,stemp);
	if((stemp = fillList(Pointer.REGION_MEMBER,wordMap,synMap))!=null)ret.put(TREGION_MEMBER,stemp);
	if((stemp = fillList(Pointer.SIMILAR_TO,wordMap,synMap))!=null)ret.put(TSIMILAR_TO,stemp);
	if((stemp = fillList(Pointer.TOPIC,wordMap,synMap))!=null)ret.put(TTOPIC,stemp);
	if((stemp = fillList(Pointer.TOPIC_MEMBER,wordMap,synMap))!=null)ret.put(TTOPIC_MEMBER,stemp);
	if((stemp = fillList(Pointer.USAGE,wordMap,synMap))!=null)ret.put(TUSAGE,stemp);
	if((stemp = fillList(Pointer.USAGE_MEMBER,wordMap,synMap))!=null)ret.put(TUSAGE_MEMBER,stemp);
	if((stemp = fillList(Pointer.VERB_GROUP,wordMap,synMap))!=null)ret.put(TVERB_GROUP,stemp);
	List<IWord> synsetWords = dict.getSynset(wordID.getSynsetID()).getWords();
	if(synsetWords.size()>1){
		stemp = new TreeSet<String>();
		for(IWord tword:synsetWords){
			String tstr;
			if((tstr=tword.getLemma())!=wordName){
				stemp.add(tstr);
			}
		}
		ret.put(TSYNSET, stemp);
	}
	return ret;
}
 
开发者ID:MusicCraftor,项目名称:WordNet-Explorer,代码行数:51,代码来源:WordDic.java


示例9: getRelatedMap

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public Map<IPointer, List<IWordID>> getRelatedMap() {
    return word.getRelatedMap();
}
 
开发者ID:automenta,项目名称:netentionj-desktop,代码行数:4,代码来源:WordParse.java


示例10: getRelatedWords

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public List<IWordID> getRelatedWords(IPointer ip) {
    return word.getRelatedWords(ip);
}
 
开发者ID:automenta,项目名称:netentionj-desktop,代码行数:4,代码来源:WordParse.java


示例11: testTopic

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public static void  testTopic() throws IOException{
	// construct the URL to the Wordnet dictionary directory
	File file =new File("wordnetDB/dict/");
	// construct the dictionary object and open it
	IDictionary dict = new Dictionary(file) ;
	dict.open();
	// look up first sense of the word " dog "
	WordnetStemmer ws = new WordnetStemmer(dict);
	
	
	//dog: 10114209
	//car: 2958343
	//home: 8559508
	//midnight
	IWordID wordID1 = new WordID(15168185,POS.NOUN,1);
	IWord word1 = dict.getWord(wordID1);
	
	System.out.println("LexFile = " + word1.getSynset().getLexicalFile());
	
	System.out.println("Lemma = " + word1.getLemma());
	
	System.out.println("Gloss = " + word1.getSynset().getGloss()) ;
	
	System.out.print("Synonyms: ");
	for(IWord iword : word1.getSynset().getWords())
		System.out.print(iword.getLemma() + ", ");
	System.out.println("\n-----------------------") ;
	System.out.println("related: ") ;
	
	Map<IPointer, List<ISynsetID>> k = word1.getSynset().getRelatedMap();
	for(IPointer ip : k.keySet()){
		System.out.print(ip.getName() + ": ");
		for (ISynsetID isid : k.get(ip)){
			System.out.print(isid.getOffset() + ".");
			ISynset ss = dict.getSynset(isid);
			System.out.print(ss.getPOS() + "=");
			IWord iw = dict.getWord(new WordID(ss.getOffset(),ss.getPOS(), 1));
			System.out.print(iw.getLemma() + ", ");
		}
			
		System.out.println();
	}
	
	
	/*
	for(IWordID wordID: idxWord.getWordIDs()){
		IWord word = dict.getWord(wordID);
		
		//System.out.println("Sence = " + word.getSenseKey().getLexicalID()) ;
		System.out.println("Lemma = " + word.getLemma()) ;
		System.out.println("Gloss = " + word.getSynset().getGloss()) ;
		
		System.out.println("Synonyms: ");
		
		for(IWord iword : word.getSynset().getWords())
			System.out.print(iword.getLemma() + ", ");
		System.out.println("\n-----------------------");
		
	}
	*/
	
	dict.close();
	
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:65,代码来源:WordNetTest.java


示例12: KnowledgeGraphPath

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public KnowledgeGraphPath(List<String> path, KnowledgeBase kb)
{
	this.path = path;
	
	this.concepts = new ArrayList<String>();
	this.pointers = new ArrayList<IPointer>();
	this.pointerSymbols = new ArrayList<String>();
	this.edges =  new ArrayList<KnowledgeGraphPathEdge>();
	this.weights = new ArrayList<Double>();
	
	for (int i = 0; i < path.size(); i++)
	{
		int position = i % 3;
		String element = path.get(i);
		switch (position)
		{
			case 0:
				// offsets
				concepts.add(element);
				break;
			case 1:
				// pointer (symbols)
				IPointer pointer = kb.getPointer(element);
				pointers.add(pointer);
				String pointerSymbol = element; 
				pointerSymbols.add(pointerSymbol);
				// edges
				String src = path.get(i-1);
				Double weight = Double.parseDouble(path.get(i+1));
				String target = path.get(i+2);
				KnowledgeGraphPathEdge edge =
					new KnowledgeGraphPathEdge(src, target, 
													pointerSymbol, pointer,
													weight);
				edges.add(edge);
				break;
			case 2:
				// weights
				weights.add(Double.parseDouble(element));
				break;
			default:
				break;
		}
	}
}
 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:46,代码来源:KnowledgeGraphPath.java


示例13: getPointer

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public IPointer getPointer() { return pointer; } 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:2,代码来源:BabelNetGraphEdge.java


示例14: getRelatedConceptsMap

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public abstract Multimap<IPointer, ScoredItem<String>> getRelatedConceptsMap(String concept, Language language); 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:2,代码来源:CustomKB.java


示例15: getPointer

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public abstract IPointer getPointer(String pointerSymbol); 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:2,代码来源:CustomKB.java


示例16: getPointers

import edu.mit.jwi.item.IPointer; //导入依赖的package包/类
public List<IPointer> getPointers() { return pointers; } 
开发者ID:iucl,项目名称:l2-writing-assistant,代码行数:2,代码来源:KnowledgeGraphPath.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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