Exemplo n.º 1
0
 public SemaforParseResult getSemaforParseResult(Sentence sentence, List<String> results) {
   final List<RankedScoredRoleAssignment> roleAssignments =
       copyOf(transform(results, processPredictionLine));
   List<String> tokens = Lists.newArrayListWithExpectedSize(sentence.size());
   for (Token token : sentence.getTokens()) {
     tokens.add(token.getForm());
   }
   return PrepareFullAnnotationJson.getSemaforParse(roleAssignments, tokens);
 }
Exemplo n.º 2
0
 /**
  * Convert to the weird format that {@link #predictArgumentLines} expects.
  *
  * @param sentence the input sentence
  * @param idResults a list of (target, frame) pairs
  * @return a list of strings in the format that {@link #predictArgumentLines} expects.
  */
 private List<String> getArgumentIdInput(
     Sentence sentence, List<Pair<List<Integer>, String>> idResults) {
   final List<String> idResultLines = Lists.newArrayList();
   final String parseLine = AllLemmaTags.makeLine(sentence.toAllLemmaTagsArray());
   for (Pair<List<Integer>, String> targetAndFrame : idResults) {
     final List<Integer> targetTokenIdxs = targetAndFrame.first;
     final String frame = targetAndFrame.second;
     final String tokenIdxsStr = Joiner.on("_").join(targetTokenIdxs);
     final Pair<String, String> tokenRepresentation =
         getTokenRepresentation(tokenIdxsStr, parseLine);
     final String lexicalUnit = tokenRepresentation.first;
     final String tokenStrs = tokenRepresentation.second;
     idResultLines.add(TAB.join(0, 1.0, 1, frame, lexicalUnit, tokenIdxsStr, tokenStrs, 0));
   }
   return idResultLines;
 }