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


Java PatriciaTrie类代码示例

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


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

示例1: plus

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public synchronized void plus(PatriciaTrie<String, Integer> another) {
	for (Entry<String, Integer> e: another.entrySet()){
		Integer score = get(e.getKey());
		score = score == null ? e.getValue() : e.getValue() + score;
		put(e.getKey(), score);
	}
}
 
开发者ID:shuoyangd,项目名称:LinguaView,代码行数:8,代码来源:PerceptronClassifier.java

示例2: minus

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public synchronized void minus(PatriciaTrie<String, Integer> another){
	for (Entry<String, Integer> e: another.entrySet()){
		Integer score = get(e.getKey());
		score = score == null ? - e.getValue() : score - e.getValue();
		put(e.getKey(), score);
	}
}
 
开发者ID:shuoyangd,项目名称:LinguaView,代码行数:8,代码来源:PerceptronClassifier.java

示例3: Dictionary

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public Dictionary(boolean loadDefault){
    trie = new PatriciaTrie<String, Double>(StringKeyAnalyzer.CHAR);
    if(loadDefault)
    	loadDicFile(DEFAULT_DIC_NAME);
}
 
开发者ID:profullstack,项目名称:cjk-mmseg,代码行数:6,代码来源:Dictionary.java

示例4: StringSparseVector

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public StringSparseVector(Parameters params) {
	this.params = params;
	this.vector = new PatriciaTrie<String, Double>(StringKeyAnalyzer.CHAR);
}
 
开发者ID:tticoin,项目名称:JointER,代码行数:5,代码来源:StringSparseVector.java

示例5: main

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public static void main(String args[]) throws IOException{
		PerceptronClassifier weight = new PerceptronClassifier();
		FeatureSet featSet = new FeatureSet();
		featSet.put("好雨知时节");
		featSet.put("当春乃发生");
		featSet.put("随风潜入夜");
		featSet.put("润物细无声");
		featSet.put("润物细无声");
		
		LogInfo.logs(featSet);
		
		LogInfo.logs(weight);
		
		LogInfo.logs(weight.score(featSet));
		weight.plus(featSet);
		LogInfo.logs(weight);
		LogInfo.logs(weight.score(featSet));		
		weight.put("润物细无声", 1);
		LogInfo.logs(weight);
		LogInfo.logs(weight.score(featSet));
		
		PatriciaTrie<String, Integer> feat = new PatriciaTrie<String, Integer>(StringKeyAnalyzer.CHAR);
		feat.put("抽烟", 1);
		feat.put("抽烟", 1);
		feat.put("喝酒", 1);
		feat.put("烫头", 1);
		
		PerceptronClassifier feat2 = new PerceptronClassifier();
		feat2.put("洗衣", 1);
		feat2.put("做饭", 1);
		
		PatriciaTrie<String, Integer> feat3 = new PatriciaTrie<String, Integer>(StringKeyAnalyzer.CHAR);
		feat3.put("做饭", 1);
		feat3.put("抽烟", 1);
		feat3.put("烫头", 1);
		feat3.put("路痴", 1);
		
//		PerceptronClassifier feat4 = feat2.clone();
//		feat2.clear();
//		System.out.println("+++" + feat4);
//		
		System.out.println("none:" + weight.score(feat2));
		weight.plus(feat2);
		System.out.println("after pending 2 score 1: " + weight.score(feat));
		System.out.println("after pending 2 score 2: " + weight.score(feat2));
		System.out.println("after pending 2 score 3: " + weight.score(feat3));
		
		weight.minus(feat);
		System.out.println("after substracting 1 score 3: " + weight.score(feat3));
		
		weight.plus(feat3);
		System.out.println(weight);
		weight.rebuild();
		System.out.println(weight);
		
		PipedOutputStream os = new PipedOutputStream();
		PipedInputStream pi = new PipedInputStream(os);

		PrintWriter pw = new PrintWriter(os);
		weight.dump(pw);
		pw.println();
		pw.println("hahaha"); //test
		pw.close();
		
		BufferedReader bt =new BufferedReader(new InputStreamReader(pi));
		PerceptronClassifier another = new PerceptronClassifier();
		another.load(bt);
		bt.close();
		System.out.println(another);
		
		os.close();
		pi.close();
		
		
	}
 
开发者ID:shuoyangd,项目名称:LinguaView,代码行数:76,代码来源:PerceptronClassifier.java

示例6: loadMarkup

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public static void loadMarkup(BufferedReader br) throws IOException{

		List<String> plainCache = new ArrayList<String>();
		List<String> indexedCache = new ArrayList<String>();
		
		String s = br.readLine();
		int state = 0;
		String plainCat = null;
		String indexedCat = null;
		
		int line = 0;
		while (s != null){
			if (s.equals("EOP")) break;
			line++;
			s = s.trim();
			if (s.length() == 0){
				if (state == 1)
					LogInfo.warning("Wrong Format at line" + line);
				else if(state > 0){
					plainCache.add(plainCat);
					indexedCache.add(indexedCat);
				}
				state = 0;
			}else{
				s = s.replaceAll("#.*$", "").trim();
				if (s.length() != 0){
					switch(state){
					case 0:
						plainCat = s;
						state = 1;
						break;
					case 1:
						indexedCat = s;
						state = 2;
						break;
					case 2:
						if (s.charAt(0) == '!'){
							char c = indexedCat.charAt(0);
							s.replace('!', c);
							break;
						}
					case 3:
						state = 3;
						//TODO GR;
					}
				}
			}
			s = br.readLine();
		}
		if (state == 1) // when gr is done, state==2 is also not illegal
			LogInfo.warning("Incomplete File");
		else if(state > 0){
			plainCache.add(plainCat);
			indexedCache.add(indexedCat);
		}
		PatriciaTrie<String, String> _cache = new PatriciaTrie<String, String>(StringKeyAnalyzer.CHAR);
		for (int i = 0; i< plainCache.size(); ++i){
			String pcat = plainCache.get(i);
			_cache.put(pcat.replace('(', '{').replace(')', '}'), indexedCache.get(i)); 
		}
		CCGTerminalNode.setInterpret(_cache);
	}
 
开发者ID:shuoyangd,项目名称:LinguaView,代码行数:63,代码来源:CCGParseResult.java

示例7: setInterpret

import org.ardverk.collection.PatriciaTrie; //导入依赖的package包/类
public static void setInterpret(PatriciaTrie<String, String> interpretation){
	_interpretation = interpretation;
}
 
开发者ID:shuoyangd,项目名称:LinguaView,代码行数:4,代码来源:CCGTerminalNode.java


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