// Path: src/main/java/io/aif/language/common/IGrouper.java
// public interface IGrouper {
// 
//   public List<Set<String>> group(final Collection<String> tokens);
// }
// 
// Path: src/main/java/io/aif/language/common/settings/ISettings.java
// public interface ISettings {
// 
//   @Deprecated
//   public ISettings SETTINGS = Guice.createInjector(new SettingsModule()).getInstance(ISettings.class);
// 
//   public String getVersion();
// 
//   public int recommendedMinimumTokensInputCount();
// 
//   public boolean useIsAlphabeticMethod();
// 
//   public double thresholdPForSeparatorCharacterInSecondFilter();
// 
//   public int minimalValuableTokenSizeForSentenceSplit();
// 
//   public int minimumCharacterObservationsCountForMakingCharacterValuableDuringSentenceSplitting();
// 
//   public double thresholdPFirstFilterForSeparatorCharacter();
// 
//   public double splitterCharactersGrouperSearchStep();
// 
//   public double splitterCharactersGrouperInitSearchPValue();
// 
//   public double wordSetDictComparatorThreshold();
// 
//   public double recursiveSubstringComparatorWeight();
// 
//   public double simpleTokenComparatorWeight();
// 
//   public double characterDensityComparatorWeight();
// 
//   public String predefinedSeparators();
// }
// 
// Path: src/main/java/io/aif/language/common/settings/SettingsModule.java
// public class SettingsModule extends AbstractModule {
// 
//   @Override
//   protected void configure() {
//     bind(ISettings.class).toProvider(new PropertyBasedSettings.Provider());
//   }
// 
// }
// 
// Path: src/main/java/io/aif/language/word/comparator/IGroupComparator.java
// public interface IGroupComparator {
// 
//   public static IGroupComparator createDefaultInstance(final ITokenComparator tokenComparator) {
//     return new OptimisedMeshComparator(tokenComparator);
//   }
// 
//   public double compare(final Collection<String> t1, final Collection<String> t2);
// 
//   public enum Type {
//     PRIMITIVE(new PrimitiveComparator());
// 
//     private final IGroupComparator setComparator;
// 
//     Type(IGroupComparator setComparator) {
//       this.setComparator = setComparator;
//     }
// 
//     public IGroupComparator getComparator() {
//       return setComparator;
//     }
// 
//   }
// 
// }


import com.google.inject.Guice;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import io.aif.language.common.IGrouper;
import io.aif.language.common.settings.ISettings;
import io.aif.language.common.settings.SettingsModule;
import io.aif.language.word.comparator.IGroupComparator;
import static org.mockito.Matchers.anySet;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
    when(groupComparator.compare(anySet(), anySet())).thenReturn(GT_COMPARATOR_THRESHOLD);

    IGrouper grouper = new FormGrouper(groupComparator);
    List<Set<String>> actual = grouper.group(input);
    assertEquals(actual, expected);
  }

  @Test(groups = "unit-tests")
  public void testGroupNoTokensAreSimilar() throws Exception {
    List<String> input = Arrays.asList("aa", "bbb", "cccc", "dddd");
    List<Set<String>> expected = new ArrayList<>();
    input.forEach(token -> expected.add(new HashSet<>(Arrays.asList(token))));

    IGroupComparator groupComparator = mock(IGroupComparator.class);
    when(groupComparator.compare(anySet(), anySet())).thenReturn(LT_COMPARATOR_THRESHOLD);

    IGrouper grouper = new FormGrouper(groupComparator);
    List<Set<String>> actual = grouper.group(input);
    assertEquals(actual, expected);
  }

  @Test(groups = "unit-tests")
  public void testGroupSomeTokensAreSimilar() throws Exception {
    List<String> input = Arrays.asList("hi", "hiya", "cat", "catty", "brat");
    List<?> expected = new ArrayList<Set<String>>() {{
      add(new HashSet<>(Arrays.asList(input.get(0), input.get(1))));
      add(new HashSet<>(Arrays.asList(input.get(2), input.get(3))));
      add(new HashSet<>(Arrays.asList(input.get(4))));
    }};
    List<Set<String>> mockSets = new ArrayList<>();
// Path: src/main/java/io/aif/language/common/IGrouper.java
// public interface IGrouper {
// 
//   public List<Set<String>> group(final Collection<String> tokens);
// }
// 
// Path: src/main/java/io/aif/language/common/settings/ISettings.java
// public interface ISettings {
// 
//   @Deprecated
//   public ISettings SETTINGS = Guice.createInjector(new SettingsModule()).getInstance(ISettings.class);
// 
//   public String getVersion();
// 
//   public int recommendedMinimumTokensInputCount();
// 
//   public boolean useIsAlphabeticMethod();
// 
//   public double thresholdPForSeparatorCharacterInSecondFilter();
// 
//   public int minimalValuableTokenSizeForSentenceSplit();
// 
//   public int minimumCharacterObservationsCountForMakingCharacterValuableDuringSentenceSplitting();
// 
//   public double thresholdPFirstFilterForSeparatorCharacter();
// 
//   public double splitterCharactersGrouperSearchStep();
// 
//   public double splitterCharactersGrouperInitSearchPValue();
// 
//   public double wordSetDictComparatorThreshold();
// 
//   public double recursiveSubstringComparatorWeight();
// 
//   public double simpleTokenComparatorWeight();
// 
//   public double characterDensityComparatorWeight();
// 
//   public String predefinedSeparators();
// }
// 
// Path: src/main/java/io/aif/language/common/settings/SettingsModule.java
// public class SettingsModule extends AbstractModule {
// 
//   @Override
//   protected void configure() {
//     bind(ISettings.class).toProvider(new PropertyBasedSettings.Provider());
//   }
// 
// }
// 
// Path: src/main/java/io/aif/language/word/comparator/IGroupComparator.java
// public interface IGroupComparator {
// 
//   public static IGroupComparator createDefaultInstance(final ITokenComparator tokenComparator) {
//     return new OptimisedMeshComparator(tokenComparator);
//   }
// 
//   public double compare(final Collection<String> t1, final Collection<String> t2);
// 
//   public enum Type {
//     PRIMITIVE(new PrimitiveComparator());
// 
//     private final IGroupComparator setComparator;
// 
//     Type(IGroupComparator setComparator) {
//       this.setComparator = setComparator;
//     }
// 
//     public IGroupComparator getComparator() {
//       return setComparator;
//     }
// 
//   }
// 
// }


// Path: src/test/unit/java/io/aif/language/word/dict/FormGrouperTest.java
import com.google.inject.Guice;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import io.aif.language.common.IGrouper;
import io.aif.language.common.settings.ISettings;
import io.aif.language.common.settings.SettingsModule;
import io.aif.language.word.comparator.IGroupComparator;
import static org.mockito.Matchers.anySet;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;

    when(groupComparator.compare(anySet(), anySet())).thenReturn(GT_COMPARATOR_THRESHOLD);

    IGrouper grouper = new FormGrouper(groupComparator);
    List<Set<String>> actual = grouper.group(input);
    assertEquals(actual, expected);
  }

  @Test(groups = "unit-tests")
  public void testGroupNoTokensAreSimilar() throws Exception {
    List<String> input = Arrays.asList("aa", "bbb", "cccc", "dddd");
    List<Set<String>> expected = new ArrayList<>();
    input.forEach(token -> expected.add(new HashSet<>(Arrays.asList(token))));

    IGroupComparator groupComparator = mock(IGroupComparator.class);
    when(groupComparator.compare(anySet(), anySet())).thenReturn(LT_COMPARATOR_THRESHOLD);

    IGrouper grouper = new FormGrouper(groupComparator);
    List<Set<String>> actual = grouper.group(input);
    assertEquals(actual, expected);
  }

  @Test(groups = "unit-tests")
  public void testGroupSomeTokensAreSimilar() throws Exception {
    List<String> input = Arrays.asList("hi", "hiya", "cat", "catty", "brat");
    List<?> expected = new ArrayList<Set<String>>() {{
      add(new HashSet<>(Arrays.asList(input.get(0), input.get(1))));
      add(new HashSet<>(Arrays.asList(input.get(2), input.get(3))));
      add(new HashSet<>(Arrays.asList(input.get(4))));
    }};
    List<Set<String>> mockSets = new ArrayList<>();
    input.forEach(token -> mockSets.add(new HashSet<>(Arrays.asList(token))));