// Path: src/main/java/io/aif/language/ner/NERExtractor.java
// public class NERExtractor {
// 
//     public Optional<Type> getNerType(final IWord word) {
//         return Arrays.stream(Type.values())
//                 .filter(nerType -> nerType.contains(word).isTrue())
//                 .findAny();
//     }
// }
// 
// 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.List;
import java.util.Set;
import java.util.stream.Collectors;
import io.aif.graph.simple.ISimpleGraph;
import io.aif.graph.simple.ISimpleGraphBuilder;
import io.aif.language.ner.NERExtractor;
import io.aif.language.word.IWord;
package io.aif.language.fact;



public class Factr {

  private final IFactDefiner factDefiner;

  private final NERExtractor nerExtractor;

  public Factr(final IFactDefiner definer, final NERExtractor nerExtractor) {
    this.factDefiner = definer;
    this.nerExtractor = nerExtractor;
  }

  public Factr() {
    this(IFactDefiner.Type.SIMPLE_FACT.getInstance(), new NERExtractor());
  }

  // TODO Move this to the graph class. Should take a lambda to build graph
  private static ISimpleGraph<IFact> buildGraph(final List<IFact> facts) {
    final ISimpleGraphBuilder<IFact> g = ISimpleGraphBuilder.defaultBuilder();
    for (int i = 0; i < facts.size(); i++) {
      IFact from = facts.get(i);
      for (int j = i + 1; j < facts.size(); j++) {
        IFact to = facts.get(j);
        if (hasCommonProperNoun(from, to))
          g.connect(from, to);
      }
    }
    return g.build();
  }

  // TODO move this as a method to fact class
  private static boolean hasCommonProperNoun(IFact sf1, IFact sf2) {
// Path: src/main/java/io/aif/language/ner/NERExtractor.java
// public class NERExtractor {
// 
//     public Optional<Type> getNerType(final IWord word) {
//         return Arrays.stream(Type.values())
//                 .filter(nerType -> nerType.contains(word).isTrue())
//                 .findAny();
//     }
// }
// 
// 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/fact/Factr.java
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import io.aif.graph.simple.ISimpleGraph;
import io.aif.graph.simple.ISimpleGraphBuilder;
import io.aif.language.ner.NERExtractor;
import io.aif.language.word.IWord;

package io.aif.language.fact;



public class Factr {

  private final IFactDefiner factDefiner;

  private final NERExtractor nerExtractor;

  public Factr(final IFactDefiner definer, final NERExtractor nerExtractor) {
    this.factDefiner = definer;
    this.nerExtractor = nerExtractor;
  }

  public Factr() {
    this(IFactDefiner.Type.SIMPLE_FACT.getInstance(), new NERExtractor());
  }

  // TODO Move this to the graph class. Should take a lambda to build graph
  private static ISimpleGraph<IFact> buildGraph(final List<IFact> facts) {
    final ISimpleGraphBuilder<IFact> g = ISimpleGraphBuilder.defaultBuilder();
    for (int i = 0; i < facts.size(); i++) {
      IFact from = facts.get(i);
      for (int j = i + 1; j < facts.size(); j++) {
        IFact to = facts.get(j);
        if (hasCommonProperNoun(from, to))
          g.connect(from, to);
      }
    }
    return g.build();
  }

  // TODO move this as a method to fact class
  private static boolean hasCommonProperNoun(IFact sf1, IFact sf2) {
    for (IWord node : sf1.getNamedEntities()) {