예제 #1
0
 private void getThirdThirdSupArgFeats(
     FeaturizedToken pred,
     FeaturizedToken arg,
     FeaturizedToken predLast,
     FeaturizedToken predNext,
     FeaturizedToken argLast,
     FeaturizedToken argNext,
     FeaturizedToken argParent,
     ArrayList<FeaturizedToken> argChildrenObjectList,
     ArrayList<String> feats) {
   String feat;
   // a.lowSupportVerb.lemma
   feats.add(getFeatureObject(arg.getLowSupportNoun()).getLemma());
   // a.lemma + a.h.form
   feats.add(arg.getLemma() + "_" + argParent.getForm());
   // a.lemma + a.pphead.form
   feats.add(arg.getLemma() + "_" + getFeatureObject(arg.getParent()).getForm());
   // a1.lemma
   feats.add(argNext.getLemma());
   // a.pos + a.children.dprel.bag
   ArrayList<String> argChildrenDeprel = new ArrayList<String>();
   for (FeaturizedToken child : argChildrenObjectList) {
     argChildrenDeprel.add(child.getDeprel());
   }
   ArrayList<String> argChildrenDeprelBag = bag(argChildrenDeprel);
   feat = arg.getPos() + buildString(argChildrenDeprelBag);
   feats.add(feat);
 }
예제 #2
0
 // ---------- 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.
 }
예제 #3
0
  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.
  }
예제 #4
0
  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);
  }
예제 #5
0
 private void getSecondThirdSupArgFeats(
     FeaturizedToken pred,
     FeaturizedToken arg,
     FeaturizedToken predLast,
     FeaturizedToken predNext,
     FeaturizedToken argLast,
     FeaturizedToken argNext,
     FeaturizedToken argParent,
     ArrayList<FeaturizedToken> argChildrenObjectList,
     ArrayList<String> feats) {
   FeaturizedToken argLm = getFeatureObject(arg.getFarLeftChild());
   FeaturizedToken argRm = getFeatureObject(arg.getFarRightChild());
   FeaturizedToken argRn = getFeatureObject(arg.getNearRightChild());
   // FeatureObject argLn = getFeatureObject(arg.getNearLeftChild());
   String feat;
   // a.h.lemma
   feats.add(argParent.getLemma());
   // a.lm.dprel + a.form
   feats.add(argLm.getDeprel() + "_" + arg.getForm());
   // a.lm_1.lemma
   feats.add(getFeatureObject(argLast.getFarLeftChild()).getLemma());
   // a.lmn.pos (n=0,1)
   feats.add(argLm.getPos());
   feats.add(getFeatureObject(argNext.getFarLeftChild()).getPos());
   // a.noFarChildren.pos.bag + a.rm.form
   ArrayList<Integer> noFarChildren = arg.getNoFarChildren();
   ArrayList<String> noFarChildrenPos = new ArrayList<String>();
   for (Integer i : noFarChildren) {
     noFarChildrenPos.add(getFeatureObject(i).getPos());
   }
   ArrayList<String> argNoFarChildrenBag = bag(noFarChildrenPos);
   feat = buildString(argNoFarChildrenBag) + argRm.getForm();
   feats.add(feat);
   // a.pphead.lemma
   feats.add(getFeatureObject(arg.getParent()).getLemma());
   // a.rm.dprel + a.form
   feats.add(argRm.getDeprel() + "_" + arg.getForm());
   // a.rm_1.form
   feats.add(getFeatureObject(argLast.getFarRightChild()).getForm());
   // a.rm.lemma
   feats.add(argRm.getLemma());
   // a.rn.dprel + a.form
   feats.add(argRn.getDeprel() + "_" + arg.getForm());
 }