Exemplo n.º 1
0
 public String[] srlTriplesFull(DiscriminativeFeatureIndexers featureIndexers) {
   String[] out = new String[srlTriples.length];
   for (int i = 0; i < srlTriples.length; i++) {
     String srlTriple =
         featureIndexers.getValueOfFeature(ExtractFeatures.FEAT_SRL_TRIPLES, srlTriples[i]);
     if (srlTriple.equals("0")) {
       out[i] = "U";
     } else {
       String[] srlTripleAr = srlTriple.split(",");
       String[] srlTriplePosAr =
           featureIndexers
               .getValueOfFeature(ExtractFeatures.FEAT_SRL_TRIPLES_POS, srlTriplesPos[i])
               .split(",");
       out[i] =
           String.format(
               "<%s,%s/%s,%s/%s>:%s",
               featureIndexers.getRole(Integer.valueOf(srlTripleAr[0])), // role
               featureIndexers.getWord(Integer.valueOf(srlTripleAr[1])),
               featureIndexers.getPos(Integer.valueOf(srlTriplePosAr[1])), // arg
               featureIndexers.getWord(Integer.valueOf(srlTripleAr[2])),
               featureIndexers.getPos(Integer.valueOf(srlTriplePosAr[2])), // pred
               argComplete.get(i));
     }
   }
   return out;
 }
Exemplo n.º 2
0
 /**
  * Input srl triple is encoded with ids, to save space, in the format role_id, arg_id, pred_id.
  *
  * @param input
  * @param unlex
  * @return
  */
 private String toStringSrlTriple(
     String input, boolean unlex, DiscriminativeFeatureIndexers featureIndexers) {
   if (input.equals("0")) return "U";
   String[] ar = input.split(",");
   if (!unlex)
     return String.format(
         "<%s,%s,%s>",
         featureIndexers.getRole(Integer.valueOf(ar[0])),
         featureIndexers.getWord(Integer.valueOf(ar[1])),
         featureIndexers.getWord(Integer.valueOf(ar[2])));
   else
     return String.format(
         "<%s,%s,%s>",
         featureIndexers.getRole(Integer.valueOf(ar[0])),
         featureIndexers.getPos(Integer.valueOf(ar[1])),
         featureIndexers.getPos(Integer.valueOf(ar[2])));
 }