test_class.file: backend/project-board/src/test/java/de/adesso/projectboard/base/normalizer/RootTermDistanceCalculatorTest.java
test_class.identifier: RootTermDistanceCalculatorTest
test_case.body: @Test
      public void nearestRootTermReturnsNearestMatchingRootTerm() {
          // given
          var firstCalcRootTerm = "tomato";
          var firstCalcDerivedTerms = Set.of("tmato");
          var secondCalcRootTerm = "apple";
          var secondCalcDerivedTerms = Set.of("appel");
          var term = "apppel";
  
          var firstCalc = new RootTermDistanceCalculator(firstCalcRootTerm, firstCalcDerivedTerms);
          var secondCalc = new RootTermDistanceCalculator(secondCalcRootTerm, secondCalcDerivedTerms);
          var calculators = Set.of(firstCalc, secondCalc);
  
          // when
          var actualNearestRootTerm = RootTermDistanceCalculator.nearestRootTerm(calculators, term, 100);
  
          // then
          assertThat(actualNearestRootTerm).isEqualTo(secondCalcRootTerm);
      }
test_case.class_method_signature: RootTermDistanceCalculatorTest.nearestRootTermReturnsNearestMatchingRootTerm()
test_case.full_signature: @Test public void nearestRootTermReturnsNearestMatchingRootTerm()
test_case.identifier: nearestRootTermReturnsNearestMatchingRootTerm
test_case.invocations: of of of nearestRootTerm isEqualTo assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void nearestRootTermReturnsNearestMatchingRootTerm()
focal_class.declarator: originalRootTerm
focal_class.modifier: private final
focal_class.original_string: private final String originalRootTerm;
focal_class.type: String
focal_class.var_name: originalRootTerm
focal_class.declarator: lowerCaseRootTerm
focal_class.modifier: private final
focal_class.original_string: private final String lowerCaseRootTerm;
focal_class.type: String
focal_class.var_name: lowerCaseRootTerm
focal_class.declarator: derivedTerms
focal_class.modifier: private final
focal_class.original_string: private final Set<String> derivedTerms;
focal_class.type: Set<String>
focal_class.var_name: derivedTerms
focal_class.file: backend/project-board/src/main/java/de/adesso/projectboard/base/normalizer/RootTermDistanceCalculator.java
focal_class.identifier: RootTermDistanceCalculator
focal_class.class_method_signature: RootTermDistanceCalculator.RootTermDistanceCalculator(String rootTerm, Set<String> derivedTerms)
focal_class.full_signature: public  RootTermDistanceCalculator(String rootTerm, Set<String> derivedTerms)
focal_class.identifier: RootTermDistanceCalculator
focal_class.modifiers: public
focal_class.parameters: (String rootTerm, Set<String> derivedTerms)
focal_class.signature:  RootTermDistanceCalculator(String rootTerm, Set<String> derivedTerms)
focal_class.class_method_signature: RootTermDistanceCalculator.calculateMinimalDistance(String stringToMatch)
focal_class.full_signature: public int calculateMinimalDistance(String stringToMatch)
focal_class.identifier: calculateMinimalDistance
focal_class.modifiers: public
focal_class.parameters: (String stringToMatch)
focal_class.return: int
focal_class.signature: int calculateMinimalDistance(String stringToMatch)
focal_class.class_method_signature: RootTermDistanceCalculator.nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_class.full_signature: public static String nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_class.identifier: nearestRootTerm
focal_class.modifiers: public static
focal_class.parameters: (Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_class.return: String
focal_class.signature: String nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_class.class_method_signature: RootTermDistanceCalculator.calculateLevenshteinDistance(String firstString, String secondString)
focal_class.full_signature: private int calculateLevenshteinDistance(String firstString, String secondString)
focal_class.identifier: calculateLevenshteinDistance
focal_class.modifiers: private
focal_class.parameters: (String firstString, String secondString)
focal_class.return: int
focal_class.signature: int calculateLevenshteinDistance(String firstString, String secondString)
focal_class.class_method_signature: RootTermDistanceCalculator.mergeRootTermAndDerivedTerms()
focal_class.full_signature: private Set<String> mergeRootTermAndDerivedTerms()
focal_class.identifier: mergeRootTermAndDerivedTerms
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Set<String>
focal_class.signature: Set<String> mergeRootTermAndDerivedTerms()
focal_method.body: public static String nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold) {
          if(threshold < 0) {
              throw new IllegalArgumentException("Threshold must be greater than or equal to 0");
          }
  
          var calculatorMindDistanceEntries = distanceCalculators.parallelStream()
                  .collect(Collectors.toMap(
                          Function.identity(),
                          distanceCalculator -> distanceCalculator.calculateMinimalDistance(term)
                  ))
                  .entrySet();
  
          var minDistanceEntry = Collections.min(calculatorMindDistanceEntries, Comparator.comparingInt(Map.Entry::getValue));
  
          if(minDistanceEntry.getValue() <= threshold) {
              return minDistanceEntry.getKey().getOriginalRootTerm();
          } else {
              return term;
          }
      }
focal_method.class_method_signature: RootTermDistanceCalculator.nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_method.full_signature: public static String nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_method.identifier: nearestRootTerm
focal_method.invocations: entrySet collect parallelStream toMap identity calculateMinimalDistance min comparingInt getValue getOriginalRootTerm getKey
focal_method.modifiers: public static
focal_method.parameters: (Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)
focal_method.return: String
focal_method.signature: String nearestRootTerm(Set<RootTermDistanceCalculator> distanceCalculators, String term, int threshold)