Beispiel #1
0
  /**
   * Load configuration (only used by constructor)
   *
   * @param config
   */
  private void loadConfiguration(MeteorConfiguration config) {
    language = config.getLanguage();
    langID = config.getLangID();
    setNormalize(config.getNormalization());
    ArrayList<Double> parameters = config.getParameters();
    alpha = parameters.get(0);
    beta = parameters.get(1);
    gamma = parameters.get(2);
    delta = parameters.get(3);
    moduleWeights = config.getModuleWeights();
    aligner =
        new Aligner(
            language,
            config.getModules(),
            config.getModuleWeights(),
            config.getBeamSize(),
            config.getWordDirURL(),
            config.getSynDirURL(),
            config.getParaDirURL(),
            // Best alignments for evaluation
            Constants.PARTIAL_COMPARE_TOTAL);

    // Best weights for evaluation
    ArrayList<Integer> modules = config.getModules();
    ArrayList<Double> setWeights = new ArrayList<Double>();
    for (int module : modules) {
      if (module == Constants.MODULE_EXACT) setWeights.add(1.0);
      else if (module == Constants.MODULE_STEM) setWeights.add(0.5);
      else if (module == Constants.MODULE_SYNONYM) setWeights.add(0.5);
      else setWeights.add(0.5);
    }
    aligner.updateModuleWeights(setWeights);
    charBased = config.getCharBased();
  }
Beispiel #2
0
 /**
  * Get the Meteor sufficient statistics for a test / reference pair
  *
  * @param test
  * @param reference
  * @return
  */
 public MeteorStats getMeteorStats(String test, String reference) {
   // Normalize both
   if (normalize) {
     test = Normalizer.normalizeLine(test, langID, keepPunctuation);
     reference = Normalizer.normalizeLine(reference, langID, keepPunctuation);
   }
   // Lowercase both
   if (lowerCase) {
     test = test.toLowerCase();
     reference = reference.toLowerCase();
   }
   // Score
   Alignment alignment = aligner.align(test, reference);
   return getMeteorStats(alignment);
 }
Beispiel #3
0
 /**
  * Get the Meteor sufficient statistics for a test give a list of references
  *
  * @param test
  * @param references
  * @return
  */
 public MeteorStats getMeteorStats(String test, ArrayList<String> references) {
   // Normalize test
   if (normalize) test = Normalizer.normalizeLine(test, langID, keepPunctuation);
   if (lowerCase) test = test.toLowerCase();
   MeteorStats stats = new MeteorStats();
   stats.score = -1;
   // Score each reference
   for (String reference : references) {
     // Normalize reference
     if (normalize) reference = Normalizer.normalizeLine(reference, langID, keepPunctuation);
     if (lowerCase) reference = reference.toLowerCase();
     Alignment alignment = aligner.align(test, reference);
     MeteorStats curStats = getMeteorStats(alignment);
     if (curStats.score > stats.score) stats = curStats;
   }
   return stats;
 }
Beispiel #4
0
 /**
  * Get stats when test and reference are already tokenized and normalized (Make sure you know what
  * you're doing)
  *
  * @param test
  * @param reference
  * @return
  */
 public MeteorStats getMeteorStats(ArrayList<String> test, ArrayList<String> reference) {
   Alignment alignment = aligner.align(test, reference);
   return getMeteorStats(alignment);
 }
Beispiel #5
0
 /**
  * Update module weights without reloading resources. This is used for tuning and is likely not
  * needed for most applications
  *
  * @param moduleWeights
  */
 public void updateModuleWeights(ArrayList<Double> moduleWeights) {
   aligner.updateModuleWeights(moduleWeights);
 }