Пример #1
0
 public void testDecodeSimple() {
   System.out.println("decodeSimple");
   int[] src = {0, 1, 2};
   Object2ObjectMap<Phrase, Collection<PhraseTranslation>> phraseTable =
       new Object2ObjectOpenHashMap<Phrase, Collection<PhraseTranslation>>();
   phraseTable.put(
       new Phrase(new int[] {0}),
       Arrays.asList(new PhraseTranslation(new int[] {3}, new double[] {-1})));
   phraseTable.put(
       new Phrase(new int[] {1}),
       Arrays.asList(new PhraseTranslation(new int[] {4}, new double[] {-1})));
   phraseTable.put(
       new Phrase(new int[] {2}),
       Arrays.asList(new PhraseTranslation(new int[] {5}, new double[] {-1})));
   final IntegerLanguageModelImpl languageModel = new IntegerLanguageModelImpl();
   languageModel.put(new Phrase(new int[] {3}), new double[] {-1, -10});
   languageModel.put(new Phrase(new int[] {4}), new double[] {-1, -10});
   languageModel.put(new Phrase(new int[] {5}), new double[] {-1, -10});
   languageModel.put(
       new Phrase(new int[] {3, 4}),
       new double[] {
         -1,
       });
   languageModel.put(
       new Phrase(new int[] {4, 5}),
       new double[] {
         -1,
       });
   int lmN = 2;
   double[] weights = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
   int distiortionLimit = 3;
   int nBest = 1;
   Solution[] result =
       FidelDecoder.decode(
           src, phraseTable, languageModel, lmN, weights, distiortionLimit, nBest, 1000, false);
   assertArrayEquals(new int[] {3, 4, 5}, result[0].soln());
   assertEquals(-6, result[0].score(), 0.01);
 }
Пример #2
0
  static {
    lm.put(new Phrase(new int[] {13}), new double[] {-3.048014, -0.5595744});
    lm.put(new Phrase(new int[] {12}), new double[] {-2.942701, -0.7269722});
    lm.put(new Phrase(new int[] {9}), new double[] {-3.485496, -0.8144186});
    lm.put(new Phrase(new int[] {6}), new double[] {-3.320179, -0.4907385});
    lm.put(new Phrase(new int[] {16}), new double[] {-3.894, -0.4098516});
    lm.put(new Phrase(new int[] {15}), new double[] {-4.069491, -0.1530379});
    lm.put(new Phrase(new int[] {8}), new double[] {-2.257655, -0.6430779});
    lm.put(new Phrase(new int[] {7}), new double[] {-2.622992, -0.5401071});
    lm.put(new Phrase(new int[] {11}), new double[] {-2.871661, -0.2037089});
    lm.put(new Phrase(new int[] {14}), new double[] {-2.203269, -0.6064922});
    lm.put(new Phrase(new int[] {10}), new double[] {-4.335011, -0.5965024});

    lm.put(new Phrase(new int[] {13, 6}), new double[] {-2.456458});
    lm.put(new Phrase(new int[] {13, 8}), new double[] {-3.731876});
    lm.put(new Phrase(new int[] {13, 7}), new double[] {-1.941688});
    lm.put(new Phrase(new int[] {13, 11}), new double[] {-3.731876});
    lm.put(new Phrase(new int[] {12, 13}), new double[] {-3.280287});
    lm.put(new Phrase(new int[] {12, 6}), new double[] {-2.15744});
    lm.put(new Phrase(new int[] {12, 8}), new double[] {-2.210782});
    lm.put(new Phrase(new int[] {12, 7}), new double[] {-1.685437});
    lm.put(new Phrase(new int[] {12, 11}), new double[] {-0.4060034});
    lm.put(new Phrase(new int[] {12, 14}), new double[] {-2.426915});
    lm.put(new Phrase(new int[] {9, 13}), new double[] {-3.661454});
    lm.put(new Phrase(new int[] {9, 16}), new double[] {-2.932294});
    lm.put(new Phrase(new int[] {9, 8}), new double[] {-3.661454});
    lm.put(new Phrase(new int[] {9, 7}), new double[] {-3.168323});
    lm.put(new Phrase(new int[] {9, 11}), new double[] {-3.168323});
    lm.put(new Phrase(new int[] {9, 14}), new double[] {-1.046571});
    lm.put(new Phrase(new int[] {6, 12}), new double[] {-2.046349});
    lm.put(new Phrase(new int[] {6, 9}), new double[] {-2.74139});
    lm.put(new Phrase(new int[] {6, 15}), new double[] {-4.246866});
    lm.put(new Phrase(new int[] {6, 8}), new double[] {-1.39645});
    lm.put(new Phrase(new int[] {6, 7}), new double[] {-4.246866});
    lm.put(new Phrase(new int[] {6, 11}), new double[] {-2.623379});
    lm.put(new Phrase(new int[] {6, 14}), new double[] {-3.753734});
    lm.put(new Phrase(new int[] {16, 13}), new double[] {-2.988746});
    lm.put(new Phrase(new int[] {16, 12}), new double[] {-2.988746});
    lm.put(new Phrase(new int[] {16, 15}), new double[] {-3.481877});
    lm.put(new Phrase(new int[] {16, 8}), new double[] {-1.976402});
    lm.put(new Phrase(new int[] {16, 7}), new double[] {-2.988746});
    lm.put(new Phrase(new int[] {16, 11}), new double[] {-2.988746});
    lm.put(new Phrase(new int[] {16, 14}), new double[] {-1.28136});
    lm.put(new Phrase(new int[] {15, 13}), new double[] {-2.974661});
    lm.put(new Phrase(new int[] {15, 12}), new double[] {-2.974661});
    lm.put(new Phrase(new int[] {15, 6}), new double[] {-3.703822});
    lm.put(new Phrase(new int[] {15, 8}), new double[] {-1.987634});
    lm.put(new Phrase(new int[] {15, 7}), new double[] {-3.703822});
    lm.put(new Phrase(new int[] {15, 11}), new double[] {-3.21069});
    lm.put(new Phrase(new int[] {15, 14}), new double[] {-2.198346});
    lm.put(new Phrase(new int[] {8, 13}), new double[] {-3.562478});
    lm.put(new Phrase(new int[] {8, 12}), new double[] {-4.242198});
    lm.put(new Phrase(new int[] {8, 9}), new double[] {-5.091981});
    lm.put(new Phrase(new int[] {8, 6}), new double[] {-3.769841});
    lm.put(new Phrase(new int[] {8, 16}), new double[] {-3.961626});
    lm.put(new Phrase(new int[] {8, 8}), new double[] {-4.398751});
    lm.put(new Phrase(new int[] {8, 7}), new double[] {-2.911189});
    lm.put(new Phrase(new int[] {8, 11}), new double[] {-1.577322});
    lm.put(new Phrase(new int[] {8, 14}), new double[] {-1.801822});
    lm.put(new Phrase(new int[] {8, 10}), new double[] {-3.961626});
    lm.put(new Phrase(new int[] {7, 13}), new double[] {-3.088698});
    lm.put(new Phrase(new int[] {7, 12}), new double[] {-2.247777});
    lm.put(new Phrase(new int[] {7, 9}), new double[] {-2.734638});
    lm.put(new Phrase(new int[] {7, 6}), new double[] {-4.273452});
    lm.put(new Phrase(new int[] {7, 16}), new double[] {-3.816251});
    lm.put(new Phrase(new int[] {7, 8}), new double[] {-1.335013});
    lm.put(new Phrase(new int[] {7, 7}), new double[] {-3.922493});
    lm.put(new Phrase(new int[] {7, 11}), new double[] {-2.750546});
    lm.put(new Phrase(new int[] {7, 14}), new double[] {-1.818335});
    lm.put(new Phrase(new int[] {11, 13}), new double[] {-1.121721});
    lm.put(new Phrase(new int[] {11, 12}), new double[] {-4.015676});
    lm.put(new Phrase(new int[] {11, 9}), new double[] {-4.954843});
    lm.put(new Phrase(new int[] {11, 6}), new double[] {-4.461711});
    lm.put(new Phrase(new int[] {11, 8}), new double[] {-3.768481});
    lm.put(new Phrase(new int[] {11, 7}), new double[] {-3.550728});
    lm.put(new Phrase(new int[] {11, 14}), new double[] {-1.549705});
    lm.put(new Phrase(new int[] {14, 13}), new double[] {-4.531987});
    lm.put(new Phrase(new int[] {14, 12}), new double[] {-5.381771});
    lm.put(new Phrase(new int[] {14, 16}), new double[] {-4.287304});
    lm.put(new Phrase(new int[] {14, 15}), new double[] {-4.287304});
    lm.put(new Phrase(new int[] {14, 8}), new double[] {-3.732888});
    lm.put(new Phrase(new int[] {14, 7}), new double[] {-2.673905});
    lm.put(new Phrase(new int[] {14, 11}), new double[] {-3.631014});
    lm.put(new Phrase(new int[] {14, 14}), new double[] {-4.531987});
    lm.put(new Phrase(new int[] {10, 13}), new double[] {-2.92767});
    lm.put(new Phrase(new int[] {10, 7}), new double[] {-2.198509});
    lm.put(new Phrase(new int[] {10, 14}), new double[] {-0.9798192});
  }