コード例 #1
0
  public BinaryDictDecoderEncoderTests(final long seed, final int maxUnigrams) {
    super();
    BinaryDictionaryUtils.setCurrentTimeForTest(0);
    Log.e(TAG, "Testing dictionary: seed is " + seed);
    final Random random = new Random(seed);
    sWords.clear();
    sWordsWithVariousCodePoints.clear();
    generateWords(maxUnigrams, random);

    for (int i = 0; i < sWords.size(); ++i) {
      sChainBigrams.put(i, new ArrayList<Integer>());
      if (i > 0) {
        sChainBigrams.get(i - 1).add(i);
      }
    }

    sStarBigrams.put(0, new ArrayList<Integer>());
    // MAX - 1 because we added one above already
    final int maxBigrams = Math.min(sWords.size(), FormatSpec.MAX_BIGRAMS_IN_A_PTNODE - 1);
    for (int i = 1; i < maxBigrams; ++i) {
      sStarBigrams.get(0).add(i);
    }

    sShortcuts.clear();
    for (int i = 0; i < NUM_OF_NODES_HAVING_SHORTCUTS; ++i) {
      final int from = Math.abs(random.nextInt()) % sWords.size();
      sShortcuts.put(sWords.get(from), new ArrayList<String>());
      for (int j = 0; j < NUM_OF_SHORTCUTS; ++j) {
        final int to = Math.abs(random.nextInt()) % sWords.size();
        sShortcuts.get(sWords.get(from)).add(sWords.get(to));
      }
    }
  }
コード例 #2
0
 @Override
 protected void tearDown() throws Exception {
   // Quit test mode.
   BinaryDictionaryUtils.setCurrentTimeForTest(-1);
   super.tearDown();
 }
コード例 #3
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   BinaryDictionaryUtils.setCurrentTimeForTest(0);
 }