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


Java DEPArc.isLabel方法代码示例

本文整理汇总了Java中com.clearnlp.dependency.DEPArc.isLabel方法的典型用法代码示例。如果您正苦于以下问题:Java DEPArc.isLabel方法的具体用法?Java DEPArc.isLabel怎么用?Java DEPArc.isLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.clearnlp.dependency.DEPArc的用法示例。


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

示例1: getNodeFromSyntacticInfo

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
private DEPNode getNodeFromSyntacticInfo(DEPNode head, ArgInfo rArg, String delim)
{
	Pair<String,String> p = rArg.popNextSyntacticInfo();
	String label = p.o1, lemma = p.o2;
	DEPNode dep;
	
	for (DEPArc arc : head.getDependents())
	{
		dep = arc.getNode();
		
		if (dep.isLemma(lemma) && (arc.isLabel(label) || (label.equals(DEPLibEn.DEP_PREP) && dep.isPos(CTLibEn.POS_IN))))
		{
			if (!rArg.hasSyntacticInfo())
				return dep;
			else
				return getNodeFromSyntacticInfo(dep, rArg, delim);
		}
	}
	
	return null;
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:22,代码来源:LGAnswerGenerator.java

示例2: countAccuracy

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
@Override
public void countAccuracy(DEPTree sTree, Object[] gSHeads)
{
	StringIntPair[][] heads = (StringIntPair[][])gSHeads;
	int i, size = sTree.size();
	StringIntPair[] gHeads;
	List<SRLArc>    sHeads;
	
	for (i=1; i<size; i++)
	{
		sHeads = sTree.get(i).getSHeads();
		gHeads = heads[i];
		
		p_total += sHeads.size();
		r_total += gHeads.length;
		
		for (StringIntPair p : gHeads)
			for (DEPArc arc : sHeads)
				if (arc.getNode().id == p.i && arc.isLabel(p.s))
					n_correct++;
	}
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:23,代码来源:SRLEval.java

示例3: relocateAuxiliary

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** {@link LGAsk#generateAskFromQuestion(DEPTree, String)}. */
private void relocateAuxiliary(DEPTree tree, DEPNode verb)
{
	List<DEPNode> auxes = new ArrayList<DEPNode>();
	DEPNode sbj = null;

	for (DEPArc arc : verb.getDependents())
	{
		if (arc.isLabel(DEPLibEn.P_AUX))
			auxes.add(arc.getNode());
		else if (arc.isLabel(DEPLibEn.P_SBJ))
			sbj = arc.getNode();
	}
	
	if (sbj != null)
	{
		if (!auxes.isEmpty() && auxes.get(0).id < sbj.id)
		{
			relocateAuxiliaryAux(tree, verb, auxes, sbj);
		}
		else if (verb.isLemma(ENAux.BE) && verb.id < sbj.id)
		{
			tree.remove(verb);
			tree.add(sbj.getLastNode().id, verb);
			setBeVerbForm(verb, sbj);
		}
	}
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:29,代码来源:LGAsk.java

示例4: isUser

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
private boolean isUser(DEPNode node)
{
	if (!USER.equalsIgnoreCase(node.form))
		return false;
	
	for (DEPArc arc : node.getDependents())
	{
		if (!arc.isLabel(DEPLibEn.DEP_DET) && !arc.isLabel(DEPLibEn.DEP_POSSESSIVE))
			return false;
	}
	
	return true;
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:14,代码来源:LGAsk.java

示例5: removeDependents

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
private void removeDependents(DEPNode root, DEPNode verb)
{
	List<DEPArc> remove = new ArrayList<DEPArc>();
	
	for (DEPArc arc : verb.getDependents())
	{
		if (arc.isLabel(P_REMOVE))
		{
			arc.getNode().setHead(root);
			remove.add(arc);
		}
	}
	
	verb.removeDependents(remove);
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:16,代码来源:LGAnswerGenerator.java

示例6: stripUnnecessaries

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
@Deprecated
private void stripUnnecessaries(DEPNode node)
{
	List<DEPArc> remove = new ArrayList<DEPArc>();
	
	for (DEPArc arc : node.getDependents())
	{
		if (arc.isLabel(DEPLibEn.DEP_PUNCT) || arc.isLabel(DEPLibEn.DEP_COMPLM) || arc.isLabel(DEPLibEn.DEP_MARK))
			remove.add(arc);
	}
	
	node.removeDependents(remove);
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:14,代码来源:LGAnswerGenerator.java

示例7: isImperative

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
public boolean isImperative(DEPNode verb)
{
	if (!verb.isPos(CTLibEn.POS_VB) && !verb.isPos(CTLibEn.POS_VBP))
		return false;
	
	if (verb.isLemma("let") || verb.isLemma("thank") || verb.isLemma("welcome"))
		return false;

	List<DEPArc> deps = verb.getDependents();
	int i, size = deps.size();
	DEPNode node;
	DEPArc  dep;
	
	for (i=0; i<size; i++)
	{
		dep  = deps.get(i);
		node = dep.getNode();
		
		if (node.id < verb.id)
		{
			if (dep.isLabel(DEPLibEn.DEP_COMPLM) || dep.isLabel(DEPLibEn.DEP_MARK))
				return false;
			
			if (dep.isLabel(P_AUX) && !node.isLemma("do"))
				return false;
			
			if ((node.isPos(CTLibEn.POS_TO) && node.containsDependent(DEPLibEn.DEP_POBJ)) || node.isPos(CTLibEn.POS_MD) || node.pos.startsWith("W"))
				return false;	
		}
		
		if (node.id < verb.id && (dep.isLabel(P_SBJ) || dep.isLabel(DEPLibEn.DEP_EXPL)))
			return false;
	}
	
	return true;
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:37,代码来源:CSenTypeClassifierEN.java

示例8: setAuxiliary

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */
private DEPNode setAuxiliary(DEPTree tree, DEPNode verb, Set<DEPNode> added, DEPNode rel)
{
	if (!verb.isLabel(DEPLibEn.DEP_XCOMP) && verb.getFirstDependentByLabel(DEPLibEn.P_SBJ) == null)
		return null;
	
	if (rel != null && DEPLibEn.P_SBJ.matcher(rel.getLabel()).find())
		return null;

	DEPNode dep;
	
	for (DEPArc arc : verb.getDependents())
	{
		dep = arc.getNode();
		
		if (arc.isLabel(DEPLibEn.P_AUX) && !dep.isPos(CTLibEn.POS_TO))
		{
			if (dep.isLemma(ENAux.GET))
				return addDoAuxiliary(tree, dep, verb);
			else
			{
				addSubtree(tree, dep, added);
				return dep;
			}
		}
	}

	if (verb.isLabel(DEPLibEn.DEP_XCOMP))
	{
		toNonFinite(verb);
		
		if (rel != null)
		{
			dep = getNode(verb, ENModal.SHOULD, ENModal.SHOULD, CTLibEn.POS_MD, DEPLibEn.DEP_AUX, SRLLib.ARGM_MOD);
			tree.add(dep);
			tree.add(getNode(verb, ENPronoun.I, ENPronoun.I, CTLibEn.POS_PRP, DEPLibEn.DEP_NSUBJ, SRLLib.ARG0));
			verb.addFeat(DEPLib.FEAT_VERB_TYPE, WH_NON_FINITE);
			return dep;
		}
		else
		{
			verb.addFeat(DEPLib.FEAT_VERB_TYPE, NON_FINITE);
			return null;
		}
	}
		
	if (verb.isLemma(ENAux.BE))
	{
		tree .add(verb);
		added.add(verb);
		return verb;
	}
	else
		return addDoAuxiliary(tree, verb, verb);
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:56,代码来源:LGAsk.java

示例9: matchNumber

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */
private void matchNumber(DEPNode verb, DEPNode aux)
{
	for (DEPArc arc : verb.getDependents())
	{
		if (arc.isLabel(DEPLibEn.P_SBJ))
		{
			DEPNode dep = arc.getNode();
			
			if (dep.isLemma(ENPronoun.YOU))
			{
				if (aux.isLemma(ENAux.DO))
				{
					if (!aux.isPos(CTLibEn.POS_VBD) && !aux.isPos(CTLibEn.POS_VBN))
					{
						aux.form = ENAux.DO;
						aux.pos  = CTLibEn.POS_VBP;
					}
				}
				else if (aux.isLemma(ENAux.BE))
				{
					if (aux.isPos(CTLibEn.POS_VBD) || aux.isPos(CTLibEn.POS_VBN))
					{
						aux.form = ENAux.WERE;
						aux.pos  = CTLibEn.POS_VBD;
					}
					else
					{
						aux.form = ENAux.ARE;
						aux.pos  = CTLibEn.POS_VBP;
					}
				}
				else if (aux.isLemma(ENAux.HAVE))
				{
					if (!aux.isPos(CTLibEn.POS_VBD) && !aux.isPos(CTLibEn.POS_VBN))
					{
						aux.form = ENAux.HAVE;
						aux.pos  = CTLibEn.POS_VBP;
					}
				}
			}
			
			break;
		}
	}
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:47,代码来源:LGAsk.java

示例10: convertUserToYou

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */
private void convertUserToYou(DEPNode node, List<DEPNode> remove)
{
	List<DEPArc> deps = node.getDependents();
	
	if (node.isPos(CTLibEn.POS_PRPS) && !ENPronoun.is1stSingular(node.lemma))
	{
		node.form = node.lemma = ENPronoun.YOUR;
	}
	else if (node.isLabel(DEPLibEn.DEP_POSS) && isUser(node))
	{
		node.form = node.lemma = ENPronoun.YOUR;
		node.pos = CTLibEn.POS_PRPS;
		remove.addAll(node.getDependentNodeList());
	}
	else if (node.isPos(CTLibEn.POS_PRP) && !ENPronoun.is1stSingular(node.lemma) && !node.isLemma("it"))
	{
		if (node.lemma.endsWith("self"))
			node.form = node.lemma = ENPronoun.YOURSELF;
		else if (node.lemma.endsWith("s"))
			node.form = node.lemma = ENPronoun.YOURS;
		else
		{
			node.form = node.lemma = ENPronoun.YOU;
			matchYouVerb(node);
		}
	}
	else if (isUser(node))
	{
		node.form = node.lemma = ENPronoun.YOU;
		node.pos = CTLibEn.POS_PRP;
		matchYouVerb(node);
		remove.addAll(node.getDependentNodeList());
	}
	else if (!deps.isEmpty())
	{
		DEPNode poss = node.getFirstDependentByLabel(DEPLibEn.DEP_POSS);
		boolean hasPoss = (poss != null) && isUser(poss);
		DEPNode dep;
		
		for (DEPArc arc : deps)
		{
			dep = arc.getNode();
			
			if (hasPoss && arc.isLabel(DEPLibEn.DEP_DET))
				remove.add(dep);
			else
				convertUserToYou(dep, remove);
		}
		
		deps.removeAll(remove);
	}
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:54,代码来源:LGAsk.java

示例11: getLongAnswerFromDeclarative

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
@Deprecated
private void getLongAnswerFromDeclarative(DEPTree qdTree, SRLTree qsTree, DEPNode rVerb, String delim, StringBuilder build)
{
	Set<String> qPreps  = getLemmaSet(qsTree, CTLibEn.POS_IN);
	Set<String> qLabels = qsTree.getBaseLabelSet();
	boolean[] bMod = getModifierAspects(qsTree);
	boolean notAdded = true;
	DEPNode rDep, qDep;
	DEPArc  rHead;
	
	for (DEPArc rArc : rVerb.getDependents())
	{
		rDep  = rArc.getNode();
		rHead = rDep.getSHead(rVerb);
		
		if (notAdded && rDep.id > rVerb.id)
		{
			build.append(delim);
			build.append(rVerb.form);
			notAdded = false;
		}
		
		if (rArc.isLabel(DEPLibEn.DEP_CONJ) || rArc.isLabel(DEPLibEn.DEP_CC) || rArc.isLabel(DEPLibEn.DEP_PRECONJ))
			continue;
		else if (rHead == null || rHead.isLabel(SRLLib.ARGM_MOD) || rHead.isLabel(SRLLib.ARGM_NEG))
		{
			build.append(delim);
			build.append(LGLibEn.getForms(rDep, USE_COREF, delim));
		}
		else if (containsLabel(qsTree, qLabels, qPreps, SRLLib.getBaseLabel(rHead.getLabel()), rDep, bMod[0], bMod[1], bMod[2]))
		{
			if (rDep.getFeat(DEPLibEn.FEAT_PB) != null && (qDep = findPredicateInQuestion(qsTree, rHead.getLabel(), rDep.lemma)) != null) 
			{
				getLongAnswerFromDeclarative(qdTree, qdTree.getSRLTree(qDep), rDep, delim, build);
			}
			else
			{
				build.append(delim);
				build.append(LGLibEn.getForms(rDep, USE_COREF, delim));
			}
		}
	}
	
	if (notAdded)
	{
		build.append(delim);
		build.append(rVerb.form);
	}
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:50,代码来源:LGAnswerGenerator.java

示例12: isImperative

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
boolean isImperative(DEPNode verb)
{
	Pattern P_SBJ = Pattern.compile("^[nc]subj.*");
	Pattern P_AUX = Pattern.compile("^aux.*");
	
	if (verb.isLemma("let") || verb.isLemma("thank") || verb.isLemma("welcome"))
		return false;
	
	if (!verb.isPos(CTLibEn.POS_VB) && !verb.isPos(CTLibEn.POS_VBP))
		return false;
	
	if (verb.isLabel(DEPLibEn.DEP_AUX) || verb.isLabel(DEPLibEn.DEP_AUXPASS) || verb.isLabel(DEPLibEn.DEP_XCOMP) || verb.isLabel(DEPLibEn.DEP_PARTMOD) || verb.isLabel(DEPLibEn.DEP_RCMOD) || verb.isLabel(DEPLibEn.DEP_CONJ) || verb.isLabel(DEPLibEn.DEP_HMOD))
		return false;

	List<DEPArc> deps = verb.getDependents();
	int i, size = deps.size();
	DEPNode node;
	DEPArc  dep;
	
	for (i=0; i<size; i++)
	{
		dep  = deps.get(i);
		node = dep.getNode();
		
		if (node.id < verb.id)
		{
			if (dep.isLabel(DEPLibEn.DEP_COMPLM) || dep.isLabel(DEPLibEn.DEP_MARK))
				return false;
			
			if (dep.isLabel(P_AUX) && !node.isLemma("do"))
				return false;
			
			if (node.isPos(CTLibEn.POS_TO) || node.isPos(CTLibEn.POS_MD) || node.pos.startsWith("W"))
				return false;	
		}
		
		if (dep.isLabel(P_SBJ) || dep.isLabel(DEPLibEn.DEP_EXPL))
			return false;
	}
	
	return true;
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:43,代码来源:Tmp.java

示例13: relinkCoordination

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
static public void relinkCoordination(SRLTree sTree)
{
	DEPNode pred = sTree.getPredicate();
	boolean noSbj = pred.getDependentsByLabels(DEPLibEn.P_SBJ).isEmpty();
	Deque<DEPNode> conjuncts;
	List<DEPArc> arcs;
	DEPNode conj, dep;
	DEPArc sArc;

	conjuncts = DEPLibEn.getPreviousConjuncts(pred);
	
	if (!conjuncts.isEmpty())
	{
		conj = conjuncts.getLast();
		arcs = conj.getDependents();
		
		int i; for (i=arcs.size()-1; i>=0; i--)
		{
			dep = arcs.get(i).getNode();
			sArc = dep.getSHead(pred);
			
			if (noSbj && (dep.isLabel(DEPLibEn.P_SBJ) || dep.isLabel(DEPLibEn.P_AUX)) || (sArc != null && sArc.isLabel(ARGM_NEG)))
			{
				dep.setHead(pred);
				pred.addDependentFront(new DEPArc(dep, dep.getLabel()));
			}
			else if (dep.containsSHead(pred))
			{
				dep.setHead(pred);
				dep.id = pred.id+1;
				pred.addDependent(new DEPArc(dep, dep.getLabel()));
			}
		}
	}
	
	conjuncts = DEPLibEn.getNextConjuncts(pred);
	
	if (!conjuncts.isEmpty())
	{
		conj = conjuncts.getLast();
		
		for (DEPArc arc : conj.getDependents())
		{
			dep = arc.getNode();
			
			if (dep.containsSHead(pred))
			{
				dep.setHead(pred);
				pred.addDependent(new DEPArc(dep, dep.getLabel()));
			}
		}
	}
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:54,代码来源:SRLLib.java

示例14: isInterrogative

import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
public boolean isInterrogative(DEPNode verb)
{
	List<DEPArc> deps = verb.getDependents();
	int i, size = deps.size();
	boolean hasAux = false;
	DEPNode node;
	DEPArc  curr;
	String  label;
	
	for (i=size-1; i>=0; i--)
	{
		curr = deps.get(i);
		node = curr.getNode();
		
		if (node.id < verb.id || !curr.isLabel(DEPLibEn.DEP_PUNCT))
			break;
		else if (P_QM.matcher(node.lemma).find())
			return true;
	}
	
	for (i=0; i<size; i++)
	{
		curr  = deps.get(i);
		node  = curr.getNode();
		label = curr.getLabel();
		
		if (node.id < verb.id)
		{
			if (curr.isLabel(DEPLibEn.DEP_PRECONJ))
				return false;
			else if (P_AUX.matcher(label).find())
				hasAux = true;
			else if (node.pos.startsWith("W"))
				return true;
			else if (P_SBJ.matcher(label).find())
				return hasAux;
		}
		else
			break;
	}
	
	if (verb.isLemma("be") || verb.isLemma("do") || verb.isLemma("have"))
	{
		for (; i<size; i++)
		{
			curr  = deps.get(i);
			label = curr.getLabel();
			
			if (P_SBJ.matcher(label).find())
				return true;
		}			
	}
	
	return false;
}
 
开发者ID:clearnlp,项目名称:clearnlp,代码行数:56,代码来源:CSenTypeClassifierEN.java


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