private void addPatternsSmall(Item predicate, double numProp) { double wSP = weightSP_small ; double wPO = weightPO_small ; wPO = Math.min(numProp, wPO) ; wSP = Math.min(numProp, wSP) ; if ( predicate.isNode() && NodeConst.nodeRDFType.equals(predicate.getNode()) ) wPO = weightTypeO_small ; addPatterns(predicate, numProp, wSP, wPO) ; }
private void addPatternsSmall(Item predicate, double numProp) { double wSP = weightSP_small ; double wPO = weightPO_small ; wPO = Math.min(numProp, wPO) ; wSP = Math.min(numProp, wSP) ; if ( predicate.isNode() && NodeConst.nodeRDFType.equals(predicate.getNode()) ) wPO = weightTypeO_small ; addPatterns(predicate, numProp, wSP, wPO) ; }
public static Node buildNode(Item item) { if ( item.isSymbol("true") ) return NodeConst.nodeTrue ; if ( item.isSymbol("false") ) return NodeConst.nodeFalse ; if ( !item.isNode() ) BuilderLib.broken(item, "Not a node", item) ; return item.getNode() ; }
public static Node buildNode(Item item) { if ( item.isSymbol("true") ) return NodeConst.nodeTrue ; if ( item.isSymbol("false") ) return NodeConst.nodeFalse ; if ( !item.isNode() ) BuilderLib.broken(item, "Not a node", item) ; return item.getNode() ; }
public long asInteger() { if ( isNode() ) { if ( getNode().isLiteral() ) // Ignore typing. return Integer.parseInt(getNode().getLiteralLexicalForm()) ; } if ( isSymbol() ) return Integer.parseInt(getSymbol()) ; throw new ItemException("Not a literal or string: "+this) ; }
public int getInt() { if ( ! isNode() ) throw new ItemException("Not a node, can't be an integer: "+this) ; if ( ! getNode().isLiteral() ) throw new ItemException("Not a literal, can't be a integer: "+this) ; return ((Number)(getNode().getLiteralValue())).intValue() ; }
public long getInteger() { if ( ! isNode() ) throw new ItemException("Not a node, can't be an integer: "+this) ; if ( ! getNode().isLiteral() ) throw new ItemException("Not a literal, can't be a integer: "+this) ; //Integer.parseInt(getNode().getLiteralLexicalForm()) ; return ((Number)(getNode().getLiteralValue())).longValue() ; }
public int getInt() { if ( ! isNode() ) throw new ItemException("Not a node, can't be an integer: "+this) ; if ( ! getNode().isLiteral() ) throw new ItemException("Not a literal, can't be a integer: "+this) ; return ((Number)(getNode().getLiteralValue())).intValue() ; }
public long getInteger() { if ( ! isNode() ) throw new ItemException("Not a node, can't be an integer: "+this) ; if ( ! getNode().isLiteral() ) throw new ItemException("Not a literal, can't be a integer: "+this) ; //Integer.parseInt(getNode().getLiteralLexicalForm()) ; return ((Number)(getNode().getLiteralValue())).longValue() ; }
public static Var buildVar(Item item) { if ( ! item.isNode() || !Var.isVar(item.getNode()) ) BuilderLib.broken(item, "Not a variable", item) ; // if ( ! Var.isNamedVar(item.getNode()) ) // BuilderBase.broken(item, "Not a named variable", item) ; return Var.alloc(item.getNode()) ; }
public static Var buildVar(Item item) { if ( ! item.isNode() || !Var.isVar(item.getNode()) ) BuilderLib.broken(item, "Not a variable", item) ; // if ( ! Var.isNamedVar(item.getNode()) ) // BuilderBase.broken(item, "Not a named variable", item) ; return Var.alloc(item.getNode()) ; }
public static void checkList(Item item, String msg) { if ( item.isList() ) return ; if ( msg == null && item.isSymbol()) msg = "Attempt to use a symbol where list expected: "+item.shortString() ; if ( msg == null && item.isNode()) msg = "Attempt to use a node where list expected: "+item.shortString() ; if ( msg == null ) msg = "Not a list" ; broken(item, msg) ; }
public String shortString() { if ( isSymbol() ) return getSymbol(); if ( isNode() ) return FmtUtils.stringForNode(getNode()); return getList().shortString() ; } }
public static boolean isSet(Item item) { if ( item.isNode() ) { if ( item.getNode().isConcrete() ) return true ; } if (item.equals(TERM) ) return true ; if (item.equals(URI) ) return true ; if (item.equals(BNODE) ) return true ; if (item.equals(LITERAL) ) return true ; return false ; }
public static boolean isSet(Item item) { if ( item.isNode() ) { if ( item.getNode().isConcrete() ) return true ; } if (item.equals(TERM) ) return true ; if (item.equals(URI) ) return true ; if (item.equals(BNODE) ) return true ; if (item.equals(LITERAL) ) return true ; return false ; }
public static Op build(Item item) { if (item.isNode() ) BuilderLib.broken(item, "Attempt to build op structure from a plain node") ; if (item.isSymbol() ) BuilderLib.broken(item, "Attempt to build op structure from a bare symbol") ; if (!item.isTagged()) BuilderLib.broken(item, "Attempt to build op structure from a non-tagged item") ; return builderOp.build(item.getList()) ; }
public void visit(ItemVisitor visitor) { if ( isList() ) visitor.visit(this, getList()) ; else if ( isNode() ) visitor.visit(this, getNode()) ; else if ( isSymbol() ) visitor.visit(this, getSymbol()) ; else if ( isNil() ) visitor.visitNil() ; else System.err.println("broken item") ; }
private static void loadGraph(Graph graph, ItemList list) { BuilderLib.checkLength(2, list, Tags.tagLoad ) ; Item item = list.get(1) ; if ( ! item.isNode() ) BuilderLib.broken(item, "Expected: ("+Tags.tagLoad+" 'filename')") ; String s = NodeUtils.stringLiteral(item.getNode()) ; if ( s == null ) BuilderLib.broken(item, "Expected: ("+Tags.tagLoad+" 'filename')") ; Model model = ModelFactory.createModelForGraph(graph) ; FileManager.get().readModel(model, s) ; }
private static void loadGraph(Graph graph, ItemList list) { BuilderLib.checkLength(2, list, Tags.tagLoad ) ; Item item = list.get(1) ; if ( ! item.isNode() ) BuilderLib.broken(item, "Expected: ("+Tags.tagLoad+" 'filename')") ; String s = NodeUtils.stringLiteral(item.getNode()) ; if ( s == null ) BuilderLib.broken(item, "Expected: ("+Tags.tagLoad+" 'filename')") ; Model model = ModelFactory.createModelForGraph(graph) ; FileManager.get().readModel(model, s) ; }
private Path build(Item item) { if (item.isNode() ) { if ( item.getNode().isURI() ) return new P_Link(item.getNode()) ; BuilderLib.broken(item, "Attempt to build path from a plain node") ; } if (item.isSymbol() ) BuilderLib.broken(item, "Attempt to build path from a bare symbol") ; return build(item.getList()) ; }