Skip to content

Commit

Permalink
Avoid additional function factory (see #417)
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Nov 4, 2023
1 parent 579aef7 commit f6519b9
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,18 @@ public static void enablingFunctions() {
log.error("", e);
}

FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "LevenshteinDistance", new SimilarityScoreFunctionFactory<>(new LevenshteinDistance()));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "CosineDistance", new SimilarityScoreFunctionFactory<>(new CosineDistance()));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "JaccardDistance", new SimilarityScoreFunctionFactory<>(new JaccardDistance()));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "JaroWinklerDistance", new SimilarityScoreFunctionFactory<>(new JaroWinklerDistance()));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "LongestCommonSubsequenceDistance", new SimilarityScoreFunctionFactory<>(new LongestCommonSubsequenceDistance()));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "HammingDistance", new SimilarityScoreFunctionFactory<>(new HammingDistance()));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "QGramDistance", new StringDistanceFunctionFactory(new QGram()));

try {
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "LevenshteinDistance", ReflectionFunctionFactory.get().makeFunction(true, LevenshteinDistance.class.getMethod("apply", CharSequence.class, CharSequence.class)));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "CosineDistance", ReflectionFunctionFactory.get().makeFunction(true, CosineDistance.class.getMethod("apply", CharSequence.class, CharSequence.class)));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "JaccardDistance", ReflectionFunctionFactory.get().makeFunction(true, JaccardDistance.class.getMethod("apply", CharSequence.class, CharSequence.class)));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "JaroWinklerDistance", ReflectionFunctionFactory.get().makeFunction(true, JaroWinklerDistance.class.getMethod("apply", CharSequence.class, CharSequence.class)));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "LongestCommonSubsequenceDistance", ReflectionFunctionFactory.get().makeFunction(true, LongestCommonSubsequenceDistance.class.getMethod("apply", CharSequence.class, CharSequence.class)));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "HammingDistance", ReflectionFunctionFactory.get().makeFunction(true, HammingDistance.class.getMethod("apply", CharSequence.class, CharSequence.class)));
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "QGramDistance", ReflectionFunctionFactory.get().makeFunction(true, QGram.class.getMethod("distance", String.class, String.class)));
} catch (NoSuchMethodException e) {
log.error("", e);
}

log.trace("Enabling function `serial`");
FunctionRegistry.get().put(Triplifier.FACADE_X_CONST_NAMESPACE_IRI + "serial", Serial.class);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit f6519b9

Please sign in to comment.