On Wed, Jul 27, 2016 at 12:36 PM, Andy Seaborne <a...@apache.org> wrote:
>
> ARQ does have some isomorphism support:
>>>
>>>    Op.isEqualTo(Op other, NodeIsomorphismMap labelMap)
>>>
>>>
>> I found only Op.equalTo (
>>
>> https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/algebra/Op.html#equalTo-org.apache.jena.sparql.algebra.Op-org.apache.jena.sparql.util.NodeIsomorphismMap-
>> ).
>>
>
> yes - that's it.  (I copied the declaration - it has argument names)


OK. I was only confused by seeing Op.isEqualTo in your example, while I
found Op.equalTo.

Why is a subclass of NodeIsomorphismMap needed instead of using
>> NodeIsomorphismMap directly? Do I need to override some methods of
>> NodeIsomorphismMap?
>>
>
> makeIsomorphic(Node n1, Node n2) says:
>
>        if ( n1.isBlank() && n2.isBlank() )
>
> and ??0 is not a blank node - it's a variable.
>
> To work round the private methods (get() and put() - I'll change that),
> you'll need to rewrite the whole thing: I tried:
>
> NodeIsomorphismMap m2 = new NodeIsomorphismMap() {
>     private Map<Node, Node> map = new HashMap<>() ;
>
>     protected Node get(Node key)
>     { return map.get(key) ; }
>
>     protected void put(Node key, Node value)
>     { map.put(key, value) ; }
>
>     @Override
>     public boolean makeIsomorphic(Node n1, Node n2)
>     {
>         if ( (Var.isBlankNodeVar(n1) || n1.isBlank() ) &&
>              ( Var.isBlankNodeVar(n2) || n2.isBlank() ) )
>         {
>             Node other = get(n1) ;
>             if ( other == null )
>             {
>                 put(n1, n2) ;
>                 return true ;
>             }
>             return other.equals(n2) ;
>         }
>         return n1.equals(n2) ;
>     }
> } ;
>

Thanks! I replicated it (in Clojure) and I can confirm that it works for my
example.

- Jindřich

Reply via email to