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


Java Predicate类代码示例

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


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

示例1: getCoreArgumentLabelSequence

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getCoreArgumentLabelSequence(Predicate pred,Map<Word, String> proposition) {
	Sentence s=pred.getMySentence();
	StringBuffer ret=new StringBuffer();
	for(int i=1;i<s.size();++i){
		Word w=s.get(i);
		if(pred==w){
			ret.append(" ").append(pred.getSense());
			if(useVoice)
				ret.append(isPassive(pred)?"/P":"/A"); 
		}
		if(proposition.containsKey(w)){
			Matcher m=CALSPattern.matcher(proposition.get(w));
			if(m.matches())
				ret.append(" ").append(m.group(1));
		}
	}
	return ret.toString();
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:20,代码来源:Spanish.java

示例2: getDefaultSense

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getDefaultSense(Predicate pred) {
	String PFeat=pred.getFeats();
	String label;
	if(PFeat.contains("postype=auxiliary")){
		label="c2";
	} else if(PFeat.contains("postype=common")) {
		label="a2";
	} else if(PFeat.contains("postype=main")) {
		label="a2";
	} else if(PFeat.contains("postype=qualificative")) {
		label="b2";
	} else if(PFeat.contains("postype=semiauxiliary")) {
		label="c2";
	} else {
		label="a2";
	}
	return pred.getLemma()+"."+label;
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:20,代码来源:Spanish.java

示例3: getCoreArgumentLabelSequence

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getCoreArgumentLabelSequence(Predicate pred, Map<Word, String> proposition) {
	Sentence sen=pred.getMySentence();
	StringBuilder ret=new StringBuilder();
	for(int i=1,size=sen.size();i<size;++i){
		Word word=sen.get(i);
		if(pred==word){
			ret.append(" "+pred.getSense()+"/");
			ret.append(isPassiveVoice(pred) ? "P" : "A");
		} //Don't make this else if, since the predicate can also be its on argument
		if(proposition.containsKey(word)){
			String label=proposition.get(word);
			if(CALSPattern.matcher(label).matches())
				ret.append(" "+label);
		}
	}
	return ret.toString();
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:19,代码来源:English.java

示例4: addInstance

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
private void addInstance(Predicate pred, LearningProblem lp) {
	String POSPrefix = getPOSPrefix(pred);
	if (POSPrefix == null) {
		POSPrefix = featureSet.POSPrefixes[0];
	}
	Collection<Integer> indices = new TreeSet<Integer>();
	Map<Integer, Double> nonbinFeats = new TreeMap<Integer, Double>();
	Integer offset = 0;
	for (Feature f : featureSet.get(POSPrefix)) {
		f.addFeatures(indices, nonbinFeats, pred, null, offset, false);
		offset += f.size(false);
	}
	Integer label = predicateReference.getLabel(pred.getLemma(), POSPrefix,
			pred.getSense());
	lp.addInstance(label, indices, nonbinFeats);
}
 
开发者ID:microth,项目名称:mateplus,代码行数:17,代码来源:PredicateDisambiguator.java

示例5: getCoreArgumentLabelSequence

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getCoreArgumentLabelSequence(Predicate pred,Map<Word, String> proposition) {
	Sentence sen=pred.getMySentence();
	StringBuilder ret=new StringBuilder();
	for(int i=1,size=sen.size();i<size;++i){
		Word word=sen.get(i);
		if(pred==word){
			ret.append(" "+pred.getSense()+"/");
			ret.append(isPassiveVoice(pred) ? "P" : "A");
		}
		if(proposition.containsKey(word)){
			ret.append(" "+proposition.get(word));
		}
	}
	
	
	return ret.toString();
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:19,代码来源:German.java

示例6: score

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
public static double score(Sentence gold, Sentence parsed) {
	if (gold.getPredicates().size() == 0
			&& parsed.getPredicates().size() == 0)
		return 1;
	int tp = 0, fp = 0;
	for (Predicate pred : parsed.getPredicates()) {
		int index = parsed.indexOf(pred);
		if (gold.get(index) instanceof Predicate
				&& ((Predicate) gold.get(index)).getSense().equals(
						pred.getSense())) {
			tp++;
		} else {
			fp++;
		}
	}
	double p = (double) tp / (tp + fp);
	double r = (double) tp / (tp + fp);
	if (p + r > 0)
		return 2 * p * r / (p + r);
	else
		return 0;
}
 
开发者ID:microth,项目名称:mateplus,代码行数:23,代码来源:PredicateDisambiguationScorer.java

示例7: train

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public void train() {
	models = new HashMap<String, Model>();
	// Here we need to do them one at a time, thats the whole reason why we
	// collected the Map<String,List<Predicate>> instances map. Otherwise we
	// would easily run out of filehandles.
	Iterator<String> it = instances.keySet().iterator();
	while (it.hasNext()) {
		String key = it.next();
		File dataFile = new File(Learn.learnOptions.tempDir, FILE_PREFIX
				+ key);
		LibLinearLearningProblem lp = new LibLinearLearningProblem(
				dataFile, false);
		for (Predicate pred : instances.get(key)) {
			addInstance(pred, lp);
		}
		lp.done();
		Model m = lp.train(true);
		models.put(key, m);
		it.remove(); // This way we should lose references to the words and
						// sentences we no longer need, and the gc should be
						// able to clean this up for us.
	}
}
 
开发者ID:microth,项目名称:mateplus,代码行数:25,代码来源:PredicateDisambiguator.java

示例8: performFeatureExtraction

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
/**
 * This method works with features that have includeArgs==false. It extracts either from all words (if boolean allWords is true), or from the predicates only (if false)
 */
@Override
protected void performFeatureExtraction(Sentence s, boolean allWords) {
	if(includeArgs){
		throw new Error("You are wrong here, check your implementation.");
	} else {
		if(allWords){
			for(int i=1,size=s.size();i<size;++i)
				if(doExtractFeatures(s.get(i)))
					addMap(getFeatureString(s,i,-1));
		} else {
			for(Predicate pred:s.getPredicates())
				if(doExtractFeatures(pred))
					addMap(getFeatureString(pred,null));
		}			
	}
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:20,代码来源:SingleFeature.java

示例9: parse

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public void parse(Sentence s) {
	for (Predicate pred : s.getPredicates()) {
		// System.err.println("Looking for arguments of " + pred.getSense()
		// + " ...");
		for (int i = 1, size = s.size(); i < size; ++i) {
			Word arg = s.get(i);

			Integer label = super.classifyInstance(pred, arg);
			if (label.equals(POSITIVE)) {
				pred.addArgMap(arg, "ARG");
			}

			// System.err.print(label.equals(POSITIVE)?"1":"0");
			// System.err.print(" " + arg.getForm() + ": ");
			// for(Word w : Word.findPath(pred, arg)) {
			// System.err.print(w.getDeprel() + " ");
			// }
			// System.err.println();
		}
	}

}
 
开发者ID:microth,项目名称:mateplus,代码行数:24,代码来源:ArgumentIdentifier.java

示例10: train

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
	public void train() {
		models=new HashMap<String,Model>();
		//Here we need to do them one at a time, thats the whole reason why we collected the Map<String,List<Predicate>> instances map. Otherwise we would easily run out of filehandles.
		Iterator<String> it=instances.keySet().iterator();
		while(it.hasNext()){
			String key=it.next();
			File dataFile=new File(Learn.learnOptions.tempDir,FILE_PREFIX+key);
			LibLinearLearningProblem lp=new LibLinearLearningProblem(dataFile,false);
			for(Predicate pred:instances.get(key)){
//				if(pred.getLemma().equals("import"))
//					System.out.println("here");
				addInstance(pred,lp);
			}
			lp.done();
			Model m=lp.train(true);
			models.put(key,m);
			it.remove(); //This way we should lose references to the words and sentences we no longer need, and the gc should be able to clean this up for us.
		}
	}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:21,代码来源:PredicateDisambiguator.java

示例11: extractLabels

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
public static void extractLabels(Iterable<Sentence> reader,PredicateReference predicateReference,List<String> argLabels) {
	if(predicateReference==null && argLabels==null)
		return;
	System.out.println("Extracting argument labels and predicate senses.");
	Set<String> argLabelSet=new HashSet<String>();
	for(Sentence s:reader){
		for(Predicate p:s.getPredicates()){
			if(predicateReference!=null)
				predicateReference.extractSense(p);
			if(argLabels!=null)
				argLabelSet.addAll(p.getArgMap().values());
		}
	}
	if(argLabels!=null)
		argLabels.addAll(argLabelSet);
	if(predicateReference!=null)
		predicateReference.trim();
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:19,代码来源:Pipeline.java

示例12: getCoreArgumentLabelSequence

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getCoreArgumentLabelSequence(Predicate pred,
		Map<Word, String> proposition) {
	Sentence s = pred.getMySentence();
	StringBuffer ret = new StringBuffer();
	for (int i = 1; i < s.size(); ++i) {
		Word w = s.get(i);
		if (pred == w) {
			ret.append(" ").append(pred.getSense());
			if (useVoice)
				ret.append(isPassive(pred) ? "/P" : "/A");
		}
		if (proposition.containsKey(w)) {
			Matcher m = CALSPattern.matcher(proposition.get(w));
			if (m.matches())
				ret.append(" ").append(m.group(1));
		}
	}
	return ret.toString();
}
 
开发者ID:microth,项目名称:mateplus,代码行数:21,代码来源:Spanish.java

示例13: getDefaultSense

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getDefaultSense(Predicate pred) {
	String PFeat = pred.getFeats();
	String label;
	if (PFeat.contains("postype=auxiliary")) {
		label = "c2";
	} else if (PFeat.contains("postype=common")) {
		label = "a2";
	} else if (PFeat.contains("postype=main")) {
		label = "a2";
	} else if (PFeat.contains("postype=qualificative")) {
		label = "b2";
	} else if (PFeat.contains("postype=semiauxiliary")) {
		label = "c2";
	} else {
		label = "a2";
	}
	return pred.getLemma() + "." + label;
}
 
开发者ID:microth,项目名称:mateplus,代码行数:20,代码来源:Spanish.java

示例14: addFeatures

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public void addFeatures(Collection<Integer> indices,
		Map<Integer, Double> nonbinFeats, Predicate pred, Word arg,
		Integer offset, boolean allWords) {
	Integer i = indexOf(getFeatureString(pred, arg));
	Double d = f1.getFeatureValue(pred, arg);
	if (i != -1 && (allWords || i < predMaxIndex))
		nonbinFeats.put(i + offset, d);
}
 
开发者ID:microth,项目名称:mateplus,代码行数:10,代码来源:QContinuousSingleFeature.java

示例15: getLexiconURL

import se.lth.cs.srl.corpus.Predicate; //导入依赖的package包/类
@Override
public String getLexiconURL(Predicate pred) {
	if(pred.getPOS().startsWith("V")){
		return "http://verbs.colorado.edu/propbank/framesets-english/"+pred.getLemma()+"-v.html";
	} else {
		return "http://nlp.cs.nyu.edu/meyers/nombank/nombank.1.0/frames/"+pred.getLemma()+".xml";
	}
}
 
开发者ID:rudaoshi,项目名称:mate,代码行数:9,代码来源:English.java


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