Package com.jgaap.util

Examples of com.jgaap.util.AbsoluteHistogram


  @Override
  public void train(List<Document> knowns) {
    Multimap<String, AbsoluteHistogram> knownHistograms = HashMultimap.create();
    for (Document known : knowns) {
      AbsoluteHistogram AbsoluteHistogram = new AbsoluteHistogram(known);
      knownHistograms.put(known.getAuthor(), AbsoluteHistogram);
    }
    ImmutableMap.Builder<String, Histogram> mapBuilder = ImmutableMap.builder();
    for (Entry<String, Collection<AbsoluteHistogram>> entry : knownHistograms.asMap().entrySet()) {
      mapBuilder.put(entry.getKey(), AbsoluteHistogram.centroid(entry.getValue()));
    }
    knownCentroids = mapBuilder.build();
  }
View Full Code Here


    knownCentroids = mapBuilder.build();
  }

  @Override
  public List<Pair<String, Double>> analyze(Document unknown) throws AnalyzeException {
    Histogram unknownHistogram = new AbsoluteHistogram(unknown);
    List<Pair<String, Double>> result = new ArrayList<Pair<String, Double>>(knownCentroids.size());
    for (Entry<String, Histogram> knownEntry : knownCentroids.entrySet()) {
      try {
        double current = distance.distance(unknownHistogram, knownEntry.getValue());
        logger.debug(unknown.getTitle()+" ("+unknown.getFilePath()+")"+" -> "+knownEntry.getKey()+":"+current);
View Full Code Here

  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();
  }
View Full Code Here

    List<AbsoluteHistogram> currentAuthorHistograms = new ArrayList<AbsoluteHistogram>(authorDocuments.size());
    for (Document document : authorDocuments) {
      if (!document.equals(known))
        currentAuthorHistograms.add(knownAbsoluteHistograms.get(document));
    }
    AbsoluteHistogram currentAuthorCentroid = AbsoluteHistogram.centroid(currentAuthorHistograms);
    AbsoluteHistogram currentAbsoluteHistogram = knownAbsoluteHistograms.get(known);
    try {
      results.add(new Pair<String, Double>(currentAuthor,distance.distance(currentAbsoluteHistogram, currentAuthorCentroid), 2));
      for (Map.Entry<String, AbsoluteHistogram> entry : knownCentroids.entrySet()) {
        if (!entry.getKey().equals(currentAuthor)) {
          results.add(new Pair<String, Double>(entry.getKey(),distance.distance(currentAbsoluteHistogram, entry.getValue()), 2));
View Full Code Here

TOP

Related Classes of com.jgaap.util.AbsoluteHistogram

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.