View Javadoc
1   package com.acumenvelocity.ath.mt.confidence;
2   
3   import java.util.Map;
4   
5   import net.sf.okapi.common.resource.TextFragment;
6   
7   /**
8    * Common data structures used across all quality estimators (Heuristic, Vertex, Hybrid).
9    */
10  public class CommonDataStructures {
11  
12    /**
13     * Represents a single source segment and all its translations from various models.
14     */
15    public static class SegmentTranslations {
16      private final int segmentId;
17      private final String sourceText;
18      private final TextFragment sourceTf;
19      private final Map<String, String> translations;
20  
21      public SegmentTranslations(int segmentId, String sourceText, TextFragment sourceTf,
22          Map<String, String> translations) {
23        this.segmentId = segmentId;
24        this.sourceText = sourceText;
25        this.sourceTf = sourceTf;
26        this.translations = translations;
27      }
28  
29      public int getSegmentId() {
30        return segmentId;
31      }
32  
33      public String getSourceText() {
34        return sourceText;
35      }
36  
37      public Map<String, String> getTranslations() {
38        return translations;
39      }
40  
41      public TextFragment getSourceTf() {
42        return sourceTf;
43      }
44    }
45  
46    /**
47     * Represents the language pair support level from the Vertex AI Quality Estimation service.
48     */
49    public static class LanguagePairSupport {
50      private final String sourceLang;
51      private final String targetLang;
52      private final String supportLevel; // FULL, COMET_ONLY, LIMITED
53      private final boolean cometSupported;
54      private final boolean metricXOptimal;
55      private final String recommendation;
56  
57      public LanguagePairSupport(String sourceLang, String targetLang, String supportLevel,
58          boolean cometSupported, boolean metricXOptimal, String recommendation) {
59  
60        this.sourceLang = sourceLang;
61        this.targetLang = targetLang;
62        this.supportLevel = supportLevel;
63        this.cometSupported = cometSupported;
64        this.metricXOptimal = metricXOptimal;
65        this.recommendation = recommendation;
66      }
67  
68      public String getSupportLevel() {
69        return supportLevel;
70      }
71  
72      public boolean isCometSupported() {
73        return cometSupported;
74      }
75  
76      public boolean isMetricXOptimal() {
77        return metricXOptimal;
78      }
79  
80      public String getRecommendation() {
81        return recommendation;
82      }
83  
84      @Override
85      public String toString() {
86        return String.format("%s→%s: %s [COMET: %s, MetricX: %s]\n%s", sourceLang, targetLang,
87            supportLevel, cometSupported ? "✓" : "✗", metricXOptimal ? "✓" : "○", recommendation);
88      }
89    }
90  }