public void train(List<Document> knowns) {
ImmutableMap.Builder<Document, AbsoluteHistogram> knownAbsoluteHistogramsBuilder = ImmutableMap.builder();
ImmutableMultimap.Builder<String, Document> knownDocumentsBuilder = ImmutableMultimap.builder();
Multimap<String, AbsoluteHistogram> knownHistograms = HashMultimap.create();
for(Document known : knowns){
AbsoluteHistogram AbsoluteHistogram = new AbsoluteHistogram(known);
knownAbsoluteHistogramsBuilder.put(known, AbsoluteHistogram);
knownHistograms.put(known.getAuthor(), AbsoluteHistogram);
knownDocumentsBuilder.put(known.getAuthor(), known);
}
knownAbsoluteHistograms = knownAbsoluteHistogramsBuilder.build();
knownDocuments = knownDocumentsBuilder.build();
ImmutableMap.Builder<String, AbsoluteHistogram> knownCentoidsBuilder = ImmutableMap.builder();
for(Map.Entry<String, Collection<AbsoluteHistogram>> entry : knownHistograms.asMap().entrySet()){
knownCentoidsBuilder.put(entry.getKey(), AbsoluteHistogram.centroid(entry.getValue()));
}
knownCentroids = knownCentoidsBuilder.build();
}