@Override public String toString() { return "OpVarMap [opMapping=" + opMap + ", varMapping=" + Iterables.toString(varMap) + "]"; } }
@Override public X getSingleResult() { List<X> items = getResultList(Range.closedOpen(0l, 2l)); if(items.size() > 1) { throw new NonUniqueResultException(); } X result = Iterables.getFirst(items, null); return result; }
/** * For property, counts how many relations with this property exist. The one * with the most relations is returned. For classes, counts how many * subtypes of this class are existing. the one with the most subtypes is * returned. If properties and classes are among the uris, the one with the * biggest count is returned. * * @param uris * @return */ public String rank(final Collection<String> uris) { Map<Integer, String> uriToQuantity = new HashMap<>(); for (String it : uris) { ArrayList<RDFNode> answers; try { answers = new ArrayList<>(sparql.sparql(constructQuery(it))); System.out.println(constructQuery(it)); RDFNode node = answers.get(0); uriToQuantity.put(((Integer) node.asLiteral().getValue()), it); } catch (ExecutionException e) { e.printStackTrace(); } } List<Integer> sorted = new ArrayList<>(uriToQuantity.keySet()); Collections.sort(sorted); return uriToQuantity.get(Iterables.getLast(sorted)); }
public static Concept createFilterConcept(Iterable<Node> nodes) { int size = Iterables.size(nodes); Element el; switch(size) { case 0: el = new ElementFilter(NodeValue.FALSE); break; case 1: Node node = nodes.iterator().next(); el = new ElementFilter(new E_Equals(new ExprVar(Vars.s), NodeValue.makeNode(node))); break; default: el = new ElementFilter(new E_OneOf(new ExprVar(Vars.s), ExprListUtils.nodesToExprs(nodes))); break; } Concept result = new Concept(el, Vars.s); return result; }
@Override public X getSingleResult() { List<X> items = getResultList(Range.closedOpen(0l, 2l)); if(items.size() > 1) { throw new NonUniqueResultException(); } X result = Iterables.getFirst(items, null); return result; }
if(logger.isDebugEnabled()) { logger.debug("Varmap: " + Iterables.toString(opVarMap.getVarMaps())); }