コード例 #1
0
 public TrainingStatistics merge(TrainingStatistics other) {
   Map<SentenceKey, EnsembleStatistics> newStats = new HashMap<>();
   // Add elements from this statistics
   for (Map<SentenceKey, EnsembleStatistics> map : this.impl) {
     for (SentenceKey key : map.keySet()) {
       newStats.put(key, new EnsembleStatistics(map.get(key)));
     }
   }
   // Add elements from other statistics
   for (Map<SentenceKey, EnsembleStatistics> map : other.impl) {
     for (SentenceKey key : map.keySet()) {
       EnsembleStatistics existing = newStats.get(key);
       if (existing == null) {
         existing = new EnsembleStatistics(new LinkedList<SentenceStatistics>());
         newStats.put(key, existing);
       }
       existing.addInPlace(map.get(key));
     }
   }
   // Return
   return new TrainingStatistics(Maybe.Just(newStats));
 }
コード例 #2
0
 public SentenceStatistics(Counter<String> relationDistribution) {
   this.confidence = Maybe.Nothing();
   this.relationDistribution = relationDistribution;
 }
コード例 #3
0
 // note that these constructors expect standard probabilities
 public SentenceStatistics(Counter<String> relationDistribution, double confidence) {
   this.confidence = Maybe.Just(confidence);
   this.relationDistribution = relationDistribution;
 }
コード例 #4
0
 public static TrainingStatistics undefined() {
   return new TrainingStatistics(Maybe.<Map<SentenceKey, EnsembleStatistics>>Nothing());
 }
コード例 #5
0
 public static TrainingStatistics empty() {
   return new TrainingStatistics(Maybe.Just(new HashMap<SentenceKey, EnsembleStatistics>()));
 }
コード例 #6
0
 public Maybe<Set<SentenceKey>> getSentenceKeys() {
   if (!impl.isDefined()) return Maybe.Nothing();
   return Maybe.Just(impl.get().keySet());
 }