// Path: src/main/java/io/aif/language/semantic/weights/node/word/TokensCountBasedWeightCalculator.java
// public class TokensCountBasedWeightCalculator implements IVertexWeightCalculator<IWord> {
// 
//   @Override
//   public Map<IWord, Double> calculate(
//       final Map<IWord, Map<IWord, Double>> vertex, final Map<IWord, Long> count) {
// 
//     return vertex.keySet()
//         .stream().collect(Collectors.toMap(node -> node, node -> calculate(node)));
//   }
// 
//   private Double calculate(final IWord node) {
//     final Set<String> mergedTokens =
//         node.getAllTokens().stream().map(String::toLowerCase).collect(Collectors.toSet());
//     return 1.0 - 1.0 / (double) mergedTokens.size();
//   }
// 
// }
// 
// Path: src/main/java/io/aif/language/word/IWord.java
// public interface IWord {
// 
//   public String getRootToken();
// 
//   public Set<String> getAllTokens();
// 
//   public Long getCount();
// 
//   public int getTokenCount(String token);
// 
//   public static interface IWordPlaceholder {
// 
//     public IWord getWord();
// 
//     public String getToken();
// 
//   }
// 
// }


import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import io.aif.associations.builder.AssociationGraph;
import io.aif.associations.builder.AssociationsGraphBuilder;
import io.aif.associations.calculators.vertex.IVertexWeightCalculator;
import io.aif.language.semantic.weights.node.word.TokensCountBasedWeightCalculator;
import io.aif.language.word.IWord;
package io.aif.language.semantic;



public class SemanticGraphBuilder {

  private final AssociationsGraphBuilder<IWord> associationsGraphBuilder;

  public SemanticGraphBuilder() {
    associationsGraphBuilder = new AssociationsGraphBuilder<>(generateWeightCalculator());
  }

  public AssociationGraph<IWord> build(final Collection<IWord.IWordPlaceholder> placeholders) {
    final List<IWord> words =
        placeholders.stream().map(IWord.IWordPlaceholder::getWord).collect(Collectors.toList());
    return associationsGraphBuilder.buildGraph(words);
  }

  private Map<IVertexWeightCalculator<IWord>, Double> generateWeightCalculator() {
    final Map<IVertexWeightCalculator<IWord>, Double> calculators = new HashMap<>();
// Path: src/main/java/io/aif/language/semantic/weights/node/word/TokensCountBasedWeightCalculator.java
// public class TokensCountBasedWeightCalculator implements IVertexWeightCalculator<IWord> {
// 
//   @Override
//   public Map<IWord, Double> calculate(
//       final Map<IWord, Map<IWord, Double>> vertex, final Map<IWord, Long> count) {
// 
//     return vertex.keySet()
//         .stream().collect(Collectors.toMap(node -> node, node -> calculate(node)));
//   }
// 
//   private Double calculate(final IWord node) {
//     final Set<String> mergedTokens =
//         node.getAllTokens().stream().map(String::toLowerCase).collect(Collectors.toSet());
//     return 1.0 - 1.0 / (double) mergedTokens.size();
//   }
// 
// }
// 
// Path: src/main/java/io/aif/language/word/IWord.java
// public interface IWord {
// 
//   public String getRootToken();
// 
//   public Set<String> getAllTokens();
// 
//   public Long getCount();
// 
//   public int getTokenCount(String token);
// 
//   public static interface IWordPlaceholder {
// 
//     public IWord getWord();
// 
//     public String getToken();
// 
//   }
// 
// }


// Path: src/main/java/io/aif/language/semantic/SemanticGraphBuilder.java
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import io.aif.associations.builder.AssociationGraph;
import io.aif.associations.builder.AssociationsGraphBuilder;
import io.aif.associations.calculators.vertex.IVertexWeightCalculator;
import io.aif.language.semantic.weights.node.word.TokensCountBasedWeightCalculator;
import io.aif.language.word.IWord;

package io.aif.language.semantic;



public class SemanticGraphBuilder {

  private final AssociationsGraphBuilder<IWord> associationsGraphBuilder;

  public SemanticGraphBuilder() {
    associationsGraphBuilder = new AssociationsGraphBuilder<>(generateWeightCalculator());
  }

  public AssociationGraph<IWord> build(final Collection<IWord.IWordPlaceholder> placeholders) {
    final List<IWord> words =
        placeholders.stream().map(IWord.IWordPlaceholder::getWord).collect(Collectors.toList());
    return associationsGraphBuilder.buildGraph(words);
  }

  private Map<IVertexWeightCalculator<IWord>, Double> generateWeightCalculator() {
    final Map<IVertexWeightCalculator<IWord>, Double> calculators = new HashMap<>();
    calculators.put(new TokensCountBasedWeightCalculator(), .85);