Class HeuristicQualityEstimator
- java.lang.Object
-
- com.acumenvelocity.ath.mt.confidence.HeuristicQualityEstimator
-
- All Implemented Interfaces:
AutoCloseable
public class HeuristicQualityEstimator extends Object implements AutoCloseable
Heuristic Quality Estimator - Fallback for unsupported language pairs Uses reference-free metrics that work for any language
-
-
Constructor Summary
Constructors Constructor Description HeuristicQualityEstimator(String projectId, String projectLocation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecalculateBackTranslationScore(String source, String translation, String sourceLang, String targetLang)Back-translation: translate back to source and compare (private helper for legacy method only) The implementation is now redundant as it's part of the inline logic above, but we keep the method signature for compatibility if it was called externally.static doublecalculateLengthRatio(String source, String translation)Calculate length ratio score (closer to 1.0 is better)static doublecalculateTextSimilarity(String text1, String text2)Calculate text similarity using character n-gram overlap (Jaccard)voidclose()List<HeuristicDataStructures.HeuristicResult>evaluateBatch(List<CommonDataStructures.SegmentTranslations> translations, String sourceLang, String targetLang)Evaluate translations using heuristic methods (OPTIMIZED - batched back-translation)HeuristicDataStructures.HeuristicScoreevaluateSingle(String sourceText, net.sf.okapi.common.resource.TextFragment sourceTf, String targetText, String srcLang, String tgtLang)HeuristicDataStructures.HeuristicScoreevaluateSingleTranslation(String source, String translation, String modelId, String sourceLang, String targetLang)Evaluate single translation (legacy method, kept for single-translation use cases)static Set<String>extractNGrams(String text, int n)Extract character n-grams
-
-
-
Constructor Detail
-
HeuristicQualityEstimator
public HeuristicQualityEstimator(String projectId, String projectLocation) throws IOException
- Throws:
IOException
-
-
Method Detail
-
evaluateBatch
public List<HeuristicDataStructures.HeuristicResult> evaluateBatch(List<CommonDataStructures.SegmentTranslations> translations, String sourceLang, String targetLang) throws IOException
Evaluate translations using heuristic methods (OPTIMIZED - batched back-translation)- Throws:
IOException
-
evaluateSingleTranslation
public HeuristicDataStructures.HeuristicScore evaluateSingleTranslation(String source, String translation, String modelId, String sourceLang, String targetLang) throws IOException
Evaluate single translation (legacy method, kept for single-translation use cases)- Throws:
IOException
-
calculateBackTranslationScore
public double calculateBackTranslationScore(String source, String translation, String sourceLang, String targetLang) throws IOException
Back-translation: translate back to source and compare (private helper for legacy method only) The implementation is now redundant as it's part of the inline logic above, but we keep the method signature for compatibility if it was called externally.- Throws:
IOException
-
calculateTextSimilarity
public static double calculateTextSimilarity(String text1, String text2)
Calculate text similarity using character n-gram overlap (Jaccard)
-
extractNGrams
public static Set<String> extractNGrams(String text, int n)
Extract character n-grams
-
calculateLengthRatio
public static double calculateLengthRatio(String source, String translation)
Calculate length ratio score (closer to 1.0 is better)
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
evaluateSingle
public HeuristicDataStructures.HeuristicScore evaluateSingle(String sourceText, net.sf.okapi.common.resource.TextFragment sourceTf, String targetText, String srcLang, String tgtLang) throws IOException
- Throws:
IOException
-
-