本文整理汇总了Java中com.clearnlp.dependency.DEPArc.getNode方法的典型用法代码示例。如果您正苦于以下问题:Java DEPArc.getNode方法的具体用法?Java DEPArc.getNode怎么用?Java DEPArc.getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.clearnlp.dependency.DEPArc
的用法示例。
在下文中一共展示了DEPArc.getNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateQuestionFromAsk
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** Generates a question from a declarative sentence with "ask". */
public DEPTree generateQuestionFromAsk(DEPTree tree)
{
tree = tree.clone();
tree.setDependents();
DEPNode root = tree.getFirstRoot();
if (root == null) return null;
DEPNode dep, dobj = null;
for (DEPArc arc : root.getDependents())
{
dep = arc.getNode();
if (MPLibEn.isVerb(dep.pos))
return generateQuestion(dep, getPrevDependents(tree, root, dep));
else if (dep.isLabel(DEPLibEn.DEP_DOBJ))
dobj = dep;
}
if (dobj != null && (dep = dobj.getFirstDependentByLabel(DEPLibEn.DEP_CCOMP)) != null)
return generateQuestion(dep, null);
return null;
}
示例2: 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;
}
示例3: getReferentArgument
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** {@link LGAsk#generateAskFromQuestion(DEPTree, String)}. */
private DEPNode getReferentArgument(DEPNode verb)
{
DEPNode dep;
for (DEPArc arc : verb.getDependents())
{
dep = arc.getNode();
if (dep.containsSHead(verb, SRLLib.P_ARG_REF))
return dep;
}
return null;
}
示例4: 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);
}
}
}
示例5: setRelativizer
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** Called by {@link LGAsk#generateQuestionFromAsk(DEPTree, String)}. */
private DEPNode setRelativizer(DEPTree tree, DEPNode verb, Set<DEPNode> added)
{
DEPNode dep, rel, head;
for (DEPArc arc : verb.getDependents())
{
dep = arc.getNode();
rel = DEPLibEn.getRefDependentNode(dep);
if (rel != null)
{
if (verb.id < rel.id)
{
head = rel.getHead();
while (head != verb && !head.isPos(CTLibEn.POS_IN) && !MPLibEn.isVerb(head.pos))
{
rel = head;
head = head.getHead();
}
}
else
{
head = rel.getHead();
while (head != verb && head.id < verb.id)
{
rel = head;
head = head.getHead();
}
}
addSubtree(tree, rel, added);
return rel;
}
}
return null;
}
示例6: 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;
}
示例7: countSemanticDependents
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
public void countSemanticDependents(String[] args)
{
SRLReader reader = new SRLReader(0, 1, 2, 3, 4, 5, 6, 8);
reader.open(UTInput.createBufferedFileReader(args[0]));
DEPTree tree;
DEPNode node, dHead, sHead;
int i;
while ((tree = reader.next()) != null)
{
tree.setDependents();
for (i=1; i<tree.size(); i++)
{
node = tree.get(i);
dHead = node.getHead();
for (DEPArc sArc : node.getSHeads())
{
sHead = sArc.getNode();
// sHead = sArc.getNode().getHead();
if (sHead != dHead && sHead != dHead.getHead() && node.isDescendentOf(sHead))
{
System.out.println(node.id+" "+sArc.getNode().id+" "+tree.toStringSRL());
try {System.in.read();} catch (IOException e) {e.printStackTrace();}
}
}
}
}
}
示例8: labelDown
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
/** Called by {@link AbstractSRLabeler#labelAux(DEPNode, IntOpenHashSet)}. */
private void labelDown(List<DEPArc> arcs, SRLState state)
{
DEPNode pred = state.getCurrentPredicate();
DEPNode arg;
for (DEPArc arc : arcs)
{
arg = arc.getNode();
if (!state.isSkip(arg))
{
state.setArgument(arg);
addArgument(getLabel(state), state);
if (state.isLowestCommonAncestor(pred))
{
if (s_down.contains(getDUPath(pred, arg)))
labelDown(arg.getDependents(), state);
else if ((arg = getPossibleDescendent(pred, arg)) != null)
labelDown(arg.getDependents(), state);
}
// if (state.isLowestCommonAncestor(pred) && s_down.contains(getDUPath(pred, arg)))
// labelDown(arg.getDependents(), state);
}
}
}
示例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;
}
}
}
示例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);
}
}
示例11: removeDependents
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
private void removeDependents(DEPNode root, DEPNode verb, Set<DEPNode> keep, boolean verbose, boolean trivialize)
{
if (verbose) return;
List<DEPArc> remove = new ArrayList<DEPArc>();
boolean changeDo = true, hasModal = false;
DEPNode dep;
for (DEPArc arc : verb.getDependents())
{
dep = arc.getNode();
if (arc.isLabel(DEPLibEn.P_AUX))
{
if (dep.isPos(CTLibEn.POS_MD) || dep.isLemma(ENAux.DO) || dep.isLemma(ENAux.HAVE))
hasModal = true;
}
else if (!keep.contains(dep) && !arc.isLabel(P_PRESERVE) && !arc.isLabel(DEPLibEn.P_SBJ))
{
dep.setHead(root);
remove.add(arc);
}
else if (dep.id > verb.id && !dep.isLabel(DEPLibEn.DEP_PUNCT))
changeDo = false;
}
verb.removeDependents(remove);
if (trivialize && changeDo && !verb.isLemma(ENAux.BE))
{
if (hasModal)
verb.form = UNConstant.EMPTY;
else
{
if (verb.isPos(CTLibEn.POS_VB) || verb.isPos(CTLibEn.POS_VBP))
verb.form = ENAux.DO;
else if (verb.isPos(CTLibEn.POS_VBZ))
verb.form = ENAux.DOES;
else if (verb.isPos(CTLibEn.POS_VBD))
verb.form = ENAux.DID;
else if (verb.isPos(CTLibEn.POS_VBN))
verb.form = ENAux.DONE;
else if (verb.isPos(CTLibEn.POS_VBG))
verb.form = ENAux.DOING;
}
verb.lemma = ENAux.DO;
}
}
示例12: 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);
}
}
示例13: addVerbNet
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
static public void addVerbNet(PVMap map, DEPTree tree)
{
int i, size = tree.size();
PVRoleset[] pvRolesets = new PVRoleset[size];
PVRoleset pvRoleset;
List<String> vnclss;
String rolesetId;
PVRole pvRole;
DEPNode node;
String n;
for (i=1; i<size; i++)
{
node = tree.get(i);
rolesetId = node.getFeat(DEPLib.FEAT_PB);
if (rolesetId != null)
{
if ((pvRoleset = map.getRoleset(rolesetId)) != null)
{
vnclss = new ArrayList<String>(pvRoleset.keySet());
Collections.sort(vnclss);
node.addFeat(DEPLib.FEAT_VN, UTCollection.toString(vnclss, DEPFeat.DELIM_VALUES));
}
pvRolesets[i] = pvRoleset;
}
}
for (i=1; i<size; i++)
for (DEPArc arc : tree.get(i).getSHeads())
if ((pvRoleset = pvRolesets[arc.getNode().id]) != null)
if (PTNumber.containsOnlyDigits(n = arc.getLabel().substring(1, 2)))
{
vnclss = new ArrayList<String>(pvRoleset.keySet());
Collections.sort(vnclss);
for (String vncls : vnclss)
if ((pvRole = pvRoleset.get(vncls).getRole(n)) != null)
arc.appendLabel(pvRole.vntheta);
}
}
示例14: expandSRL
import com.clearnlp.dependency.DEPArc; //导入方法依赖的package包/类
public String[][] expandSRL(DEPTree tree)
{
ObjectIntOpenHashMap<DEPNode> map = new ObjectIntOpenHashMap<DEPNode>();
int i = 0, predId = 0, size = tree.size();
DEPNode pred, arg;
String label;
while ((pred = tree.getNextPredicate(predId)) != null)
{
map.put(pred, i++);
predId = pred.id;
}
if (map.isEmpty()) return null;
String[][] spans = new String[size][];
int len = map.size();
for (i=1; i<size; i++)
{
spans[i] = new String[len];
Arrays.fill(spans[i], AbstractColumnReader.BLANK_COLUMN);
}
for (i=1; i<size; i++)
{
arg = tree.get(i);
for (DEPArc arc : arg.getSHeads())
{
pred = arc.getNode();
if (!map.containsKey(pred)) continue;
predId = map.get(pred);
label = arc.getLabel();
for (int spanId : getSpan(pred, arg))
spans[spanId][predId] = label;
}
}
return spans;
}
示例15: 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;
}