use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class StatsMatcher method onePattern.
private void onePattern(Item elt) {
Item pat = elt.getList().get(0);
if (pat.isNode()) {
// (<uri> weight)
Node n = pat.getNode();
if (!n.isURI()) {
log.warn("Not a preicate URI: " + pat.toString());
return;
}
addAbbreviation(elt);
} else if (pat.isSymbol()) {
if (pat.equals(OTHER)) {
double d = elt.getList().get(1).getDouble();
DefaultMatch = d;
return;
}
if (pat.equals(BNODE) || pat.equals(LITERAL)) {
log.warn("Not a match for a predicate URI: " + pat.toString());
return;
}
if (pat.equals(TERM) || pat.equals(VAR) || pat.equals(ANY))
addAbbreviation(elt);
else {
log.warn("Not understood: " + pat);
return;
}
} else if (pat.isList() && pat.getList().size() == 3) {
// It's of the form ((S P O) weight)
Item w = elt.getList().get(1);
Pattern pattern = new Pattern(((Number) (w.getNode().getLiteralValue())).doubleValue(), intern(pat.getList().get(0)), intern(pat.getList().get(1)), intern(pat.getList().get(2)));
addPattern(pattern);
} else {
log.warn("Unrecognized pattern: " + pat);
}
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class StatsMatcher method addAbbreviation.
private void addAbbreviation(Item elt) {
Item predicateTerm = elt.getList().get(0);
// Single node - it's a predicate abbreviate.
double numProp = elt.getList().get(1).getDouble();
if (count < 100)
addPatternsSmall(predicateTerm, numProp);
else
addPatterns(predicateTerm, numProp);
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class ParseHandlerResolver method emitPName.
@Override
public void emitPName(int line, int column, String pname) {
if (inFormDecl()) {
// Record a faked PName. Works with BuilderPrefixMapping
Item item = Item.createSymbol(pname, line, column);
listAdd(item);
return;
}
String iriStr = resolvePrefixedName(pname, line, column);
super.emitIRI(line, column, iriStr);
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderPath method build.
private Path build(ItemList list) {
Item head = list.get(0);
if (!head.isSymbol())
return build(head);
String tag = head.getSymbol();
Build bob = findBuild(tag);
if (bob != null)
return bob.make(list);
else
BuilderLib.broken(head, "Unrecognized path operation: " + tag);
return null;
}
use of org.apache.jena.sparql.sse.Item in project jena by apache.
the class BuilderExpr method buildExprListUntagged.
private static ExprList buildExprListUntagged(ItemList list, int idx) {
ExprList exprList = new ExprList();
for (int i = idx; i < list.size(); i++) {
Item item = list.get(i);
exprList.add(buildExpr(item));
}
return exprList;
}
Aggregations