private static int[] getNewSource(boolean isGlue, HyperEdge edge) {
   BilingualRule rule = (BilingualRule) edge.getRule();
   int[] english = rule.getEnglish();
   // if this is a unary abstract rule, just return null
   // TODO: except glue rules!
   if (english.length == 1 && english[0] < 0 && !isGlue) return null;
   int currNT = 1;
   int[] result = new int[english.length];
   for (int i = 0; i < english.length; i++) {
     int curr = english[i];
     if (!Vocabulary.nt(curr)) {
       result[i] = curr;
     } else {
       int index = -curr - 1;
       int label = getLabelWithSpan(edge.getAntNodes().get(index));
       result[i] = label * 2 - currNT;
       currNT++;
     }
   }
   // System.err.printf("source: %s\n", result);
   return result;
 }
Ejemplo n.º 2
0
 public double finalTransitionLogP(HyperEdge edge, int spanStart, int spanEnd, int sentID) {
   return finalTransitionLogP(
       edge.getAntNodes().get(0), spanStart, spanEnd, edge.getSourcePath(), sentID);
 }
Ejemplo n.º 3
0
 public double transitionLogP(HyperEdge edge, int spanStart, int spanEnd, int sentID) {
   return transitionLogP(
       edge.getRule(), edge.getAntNodes(), spanStart, spanEnd, edge.getSourcePath(), sentID);
 }