private void addZhaoSupervisedSenseFeats( FeaturizedToken p, FeaturizedToken p1, ArrayList<String> feats) { String feat; // p.lm.pos feat = getFeatureObject(p.getFarLeftChild()).getPos(); feats.add(feat); // p.rm.pos feat = getFeatureObject(p.getFarRightChild()).getPos(); feats.add(feat); // p.lemma feat = p.getLemma(); feats.add(feat); // p.lemma + p.lemma1 feat = p.getLemma() + p1.getLemma(); feats.add(feat); // p.lemma + p.children.dprel.noDup ArrayList<String> depRelChildren = new ArrayList<String>(); ArrayList<FeaturizedToken> pChildren = getFeatureObjectList(p.getChildren()); for (FeaturizedToken child : pChildren) { depRelChildren.add(child.getDeprel()); } feat = buildString(noDup(depRelChildren)); feats.add(feat); // Er...what? Sense given for sense prediction? // p.lemma + p.currentSense }
public void addZhaoPairFeatures(int pidx, int aidx, ArrayList<String> feats) { /* NOTE: Not sure about they're "Semantic Connection" features. * What do they correspond to in CoNLL data? * From paper: "This includes semantic head (semhead), left(right) farthest(nearest) * semantic child (semlm, semln, semrm, semrn). * We say a predicate is its argument's semantic head, and the latter is the former's child. * Features related to this type may track the current semantic parsing status." * If a semantic predicate is given, then the SRL task is moot... */ FeaturizedToken pred = getFeatureObject(pidx); FeaturizedToken arg = getFeatureObject(aidx); FeaturizedTokenPair predArgPair = getFeatureObject(pidx, aidx); FeaturizedToken predLast = getFeatureObject(pidx - 1); FeaturizedToken predNext = getFeatureObject(pidx + 1); // FeatureObject predParent = getFeatureObject(pred.getParent()); FeaturizedToken argLast = getFeatureObject(aidx - 1); FeaturizedToken argNext = getFeatureObject(aidx + 1); FeaturizedToken argParent = getFeatureObject(arg.getParent()); ArrayList<Integer> predChildren = pred.getChildren(); ArrayList<Integer> argChildren = arg.getChildren(); List<Pair<Integer, Dir>> dependencyPath = predArgPair.getDependencyPath(); // Initialize Path structures. // List<Pair<Integer, Dir>> dpPathPred = predArgPair.getDpPathPred(); List<Pair<Integer, Dir>> dpPathArg = predArgPair.getDpPathArg(); ArrayList<Integer> linePath = predArgPair.getLinePath(); ArrayList<FeaturizedToken> predChildrenObjectList = getFeatureObjectList(predChildren); ArrayList<FeaturizedToken> argChildrenObjectList = getFeatureObjectList(argChildren); ArrayList<FeaturizedToken> dependencyPathObjectList = getFeatureObjectList(dependencyPath); ArrayList<FeaturizedToken> linePathCoNLL = getFeatureObjectList(linePath); // Add the supervised features if (prm.withSupervision) { addZhaoSupervisedPredFeats(pred, arg, predLast, predNext, predChildrenObjectList, feats); addZhaoSupervisedArgFeats( pred, arg, predLast, predNext, argLast, argNext, argParent, argChildrenObjectList, feats); addZhaoSupervisedCombinedFeats( pred, arg, feats, dependencyPathObjectList, linePathCoNLL, dpPathArg); } // Add the unsupervised features addZhaoUnsupervisedPredFeats(pred, predLast, predNext, feats); addZhaoUnsupervisedArgFeats(arg, argLast, argNext, argChildrenObjectList, feats); addZhaoUnsupervisedCombinedFeats(linePath, linePathCoNLL, feats); }
// ---------- Bjorkelund et al, CoNLL2009 features. ---------- public void addBjorkelundSenseFeatures(int idx, ArrayList<String> feats) { FeaturizedToken pred = getFeatureObject(idx); FeaturizedToken predParent = getFeatureObject(pred.getParent()); ArrayList<Integer> predChildren = pred.getChildren(); // PredWord, PredPOS, PredDeprel, PredFeats addBjorkelundGenericFeatures(idx, feats, "Pred"); // predParentWord, predParentPOS, predParentFeats addBjorkelundPredParentFeatures(predParent, feats); // ChildDepSet, ChildWordSet, ChildPOSSet addBjorkelundPredChildFeatures(predChildren, feats); // TODO: DepSubCat: the subcategorization frame of the predicate, e.g. OBJ+OPRD+SUB. }
public void addBjorkelundPairFeatures(int pidx, int aidx, ArrayList<String> feats) { /* From Bjorkelund et al, CoNLL 2009. * Prefixes: * Pred: the predicate * PredParent: the parent of the predicate * Arg: the argument * Left: the leftmost dependent of the argument * Right: the rightmost dependent of the argument * LeftSibling: the left sibling of the argument * RightSibling: the right sibling of the argument */ String feat; FeaturizedToken pred = getFeatureObject(pidx); FeaturizedToken arg = getFeatureObject(aidx); FeaturizedTokenPair predArgPair = getFeatureObject(pidx, aidx); FeaturizedToken predParent = getFeatureObject(pred.getParent()); ArrayList<Integer> predChildren = pred.getChildren(); FeaturizedToken argLeftSibling = getFeatureObject(arg.getNearLeftSibling()); FeaturizedToken argRightSibling = getFeatureObject(arg.getNearRightSibling()); FeaturizedToken argLeftDependent = getFeatureObject(arg.getFarLeftChild()); FeaturizedToken argRightDependent = getFeatureObject(arg.getFarRightChild()); // PredWord, PredPOS, PredFeats, PredDeprel addBjorkelundGenericFeatures(pidx, feats, "Pred"); // ArgWord, ArgPOS, ArgFeats, ArgDeprel addBjorkelundGenericFeatures(aidx, feats, "Arg"); // PredParentWord, PredParentPOS, PredParentFeats addBjorkelundPredParentFeatures(predParent, feats); // ChildDepSet, ChildWordSet, ChildPOSSet addBjorkelundPredChildFeatures(predChildren, feats); // LeftWord, LeftPOS, LeftFeats addBjorkelundDependentFeats(argLeftDependent, feats, "Left"); // RightWord, RightPOS, RightFeats addBjorkelundDependentFeats(argRightDependent, feats, "Right"); // LeftSiblingWord, LeftSiblingPOS, LeftSiblingFeats addBjorkelundSiblingFeats(argLeftSibling, feats, "Left"); // RightSiblingWord, RightSiblingPOS, RightSiblingFeats addBjorkelundSiblingFeats(argRightSibling, feats, "Right"); // DeprelPath, POSPath addBjorkelundPathFeats(predArgPair, feats); // Position addBjorkelundPositionFeat(pidx, aidx, feats); // PredLemma feat = pred.getLemma(); feats.add("PredLemma:" + feat); // TODO: Sense: the value of the Pred column, e.g. plan.01. // TODO: DepSubCat: the subcategorization frame of the predicate, e.g. OBJ+OPRD+SUB. }