use of akka.japi.Function in project webofneeds by researchstudio-sat.
the class SparqlMatcherActor method processActiveAtomEvent.
/**
* Produces hints for the atom. The score is calculated as a function of scores
* provided by the embedded sparql queries: the range of those scores is
* projected on a range of 0-1. For inverse matches, the score is always 100%,
* because there is only one possible match - the original atom. Note: this
* could be improved by remembering reported match scores in the matcher and
* using historic scores for normalization, but that's a lot more work.
*/
protected void processActiveAtomEvent(AtomEvent atomEvent) throws IOException {
AtomModelWrapper atom = new AtomModelWrapper(atomEvent.deserializeAtomDataset());
log.debug("starting sparql-based matching for atom {}, cause: {}", atom.getAtomUri(), atomEvent.getCause());
List<ScoredAtom> matches = queryAtom(atom);
log.debug("found {} match candidates", matches.size());
// produce hints after post-filtering the matches we found:
Collection<HintEvent> hintEvents = produceHints(atom, // we
matches.stream().filter(foundAtom -> foundAtom.atom.getAtomState() == AtomState.ACTIVE).filter(foundAtom -> postFilter(atom, foundAtom.atom)).collect(Collectors.toList()), atomEvent.getCause());
publishHintEvents(hintEvents, atom.getAtomUri());
log.debug("finished sparql-based matching for atom {}", atom.getAtomUri());
}
Aggregations