https://github.com/oeg-upm/loom-ld
1. Write Functions
public abstract class AbstractSimilarityFunction extends FunctionBase2 implements Similarity {
private SimilarityAlgorithm algorithm;
public AbstractSimilarityFunction(SimilarityAlgorithm algorithm) {
this.algorithm = algorithm;
}
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
String element1 = v1.asString();
String element2 = v2.asString();
Double score = similarity(element1, element2);
return NodeValue.makeDouble(score);
}
public SimilarityAlgorithm getAlgorithm() {
return algorithm;
}
public void setAlgorithm(SimilarityAlgorithm algorithm) {
this.algorithm = algorithm;
}
}
2. Registration Functions
FunctionRegistry.get().put(uri, funcClass);
3. Use Custom Functions in SPARQL
PREFIX loom: <http://oeg.upm.es/loom-ld/functions/link#>
Top comments (0)