本文整理汇总了Java中com.clearnlp.dependency.DEPArc类的典型用法代码示例。如果您正苦于以下问题:Java DEPArc类的具体用法?Java DEPArc怎么用?Java DEPArc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DEPArc类属于com.clearnlp.dependency包,在下文中一共展示了DEPArc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertYouToUser
import com.clearnlp.dependency.DEPArc; //导入依赖的package包/类
/** {@link LGAsk#generateAskFromQuestion(DEPTree, String)}. */
private void convertYouToUser(DEPTree tree, DEPNode head)
{
if (head.isLemma(ENPronoun.YOU) || head.isLemma(ENPronoun.YOURSELF))
{
head.form = head.lemma = USER;
head.pos = CTLibEn.POS_NN;
matchUserVerb(head);
tree.add(tree.indexOf(head), getNode(head, UNConstant.THE, UNConstant.THE, CTLibEn.POS_DT, DEPLibEn.DEP_DET, null));
}
else if (head.isLemma(ENPronoun.YOUR) || head.isLemma(ENPronoun.YOURS))
{
int idx = tree.indexOf(head);
head.form = head.lemma = USER;
head.pos = CTLibEn.POS_NN;
tree.add(idx , getNode(head, UNConstant.THE, UNConstant.THE, CTLibEn.POS_DT, DEPLibEn.DEP_DET, null));
tree.add(idx+2, getNode(head, UNConstant.APOSTROPHE_S, UNConstant.APOSTROPHE_S, CTLibEn.POS_POS, DEPLibEn.DEP_POSSESSIVE, null));
}
for (DEPArc arc : head.getDependents())
convertYouToUser(tree, arc.getNode());
}
示例2: 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;
}
示例3: 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;
}
示例4: getXHeads
import com.clearnlp.dependency.DEPArc; //导入依赖的package包/类
private List<DEPArc> getXHeads(DEPTree tree, String heads)
{
List<DEPArc> sHeads = Lists.newArrayList();
if (heads.equals(AbstractColumnReader.BLANK_COLUMN))
return sHeads;
int headId, idx;
String label;
for (String head : heads.split(DEPLib.DELIM_HEADS))
{
idx = head.indexOf(DEPLib.DELIM_HEADS_KEY);
headId = Integer.parseInt(head.substring(0, idx));
label = head.substring(idx+1);
sHeads.add(new DEPArc(tree.get(headId), label));
}
return sHeads;
}
示例5: getArgumentList
import com.clearnlp.dependency.DEPArc; //导入依赖的package包/类
static public List<List<DEPArc>> getArgumentList(DEPTree tree)
{
int i, size = tree.size();
List<DEPArc> args;
DEPNode node;
List<List<DEPArc>> list = new ArrayList<List<DEPArc>>();
for (i=0; i<size; i++) list.add(new ArrayList<DEPArc>());
for (i=1; i<size; i++)
{
node = tree.get(i);
for (DEPArc arc : node.getSHeads())
{
args = list.get(arc.getNode().id);
args.add(new DEPArc(node, arc.getLabel()));
}
}
return list;
}
示例6: 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++;
}
}
示例7: collectUp
import com.clearnlp.dependency.DEPArc; //导入依赖的package包/类
private void collectUp(DEPNode pred, DEPNode head)
{
if (head == null) return;
for (DEPArc arc : head.getDependents())
{
if (arc.getNode().isArgumentOf(pred))
{
for (String path : getDUPathList(head, pred))
m_up.add(path);
break;
}
}
collectUp(pred, head.getHead());
}
示例8: featTestSetters
import com.clearnlp.dependency.DEPArc; //导入依赖的package包/类
@Test
public void featTestSetters()
{
DEPArc head = new DEPArc();
DEPNode node1 = new DEPNode();
DEPNode node2 = new DEPNode();
assertEquals(head.getNode() , null);
assertEquals(head.getLabel(), null);
head.set(node1, "SBJ");
assertEquals(head.getNode(), node1);
assertEquals(true, head.isNode (node1));
assertEquals(true, head.isLabel("SBJ"));
assertEquals(1, head.compareTo(node1, "SBJ"));
assertEquals(2, head.compareTo(node1, "OBJ"));
assertEquals(0, head.compareTo(node2, "SBJ"));
}
示例9: replaceDep
import com.clearnlp.dependency.DEPArc; //导入依赖的package包/类
/**
* Replace old dependency arcs into new dependency arcs
*
* @param units
* @param new_units
*/
public static void replaceDep(DEPTree units, List<TypedDependency> new_units) {
for (TypedDependency new_unit : new_units) {
DEPNode gov = units.get(new_unit.gov().label().index());
DEPNode dep = units.get(new_unit.dep().label().index());
String reln = new_unit.reln().toString();
dep.setHead(new DEPArc(gov, reln));
}
}
示例10: 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;
}
示例11: 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);
}
}
}
示例12: 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;
}
示例13: 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;
}
示例14: 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);
}
示例15: 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);
}