コード例 #1
0
  // Punish chunks whose length is other than 3.
  private static void discriminate(ChunkRanker ranker) {
    ArrayList<LexChunk> chunks = ranker.getChunks();
    for (LexChunk ch : chunks) {
      int sz = ch.size();
      double weight = sz - 3;
      if (weight < 0) weight = -weight;
      weight = 1.0 - 0.2 * weight;

      // twiddle the confidence of the chunk
      TruthValue tv = ch.getTruthValue();
      SimpleTruthValue stv = (SimpleTruthValue) tv;
      double confidence = stv.getConfidence();
      confidence *= weight;
      stv.setConfidence(confidence);
    }
  }
コード例 #2
0
 private static void prt_chunks(ArrayList<LexChunk> chunks) {
   for (LexChunk ch : chunks) {
     System.out.println(ch.toString());
   }
   System.out.println("\n======\n");
 }