Hi Mike,

Yes, I saw the example, I think you're referring to:
xquery version "1.0-ml";

import module namespace sem="http://marklogic.com/semantic";
 at "semantic.xqy";

let $m := map:map()
let $seeds := xdmp:get-request-field('seed')
let $filters as xs:string* := xdmp:get-request-field('filter')
let $gen := 6
return sem:transitive-closure(
  $m, $seeds, $gen,
  'http://xmlns.com/foaf/0.1/knows',
  true(), $filters
)

And I've seen the description of the parameters:

$m as map:map,
 $seeds as xs:string*,
 $gen as xs:integer, $relation as xs:string,
 $direction as xs:boolean,
 $filters as xs:string*

But that doesn't really tell me what is in a "seed" since there's no real 
example of the value(s).  It's a string, I get it.
For instance what does the "seeds" look like if you have more than one? 
 I'm assuming you can have more than one by the implication of the name "seeds".

The comment in the code states:
$seeds     - This stores unfiltered results, and it's used recursively for 
finding the next generation of friends

And the first thing that functions seem to do is:
count($seeds)

So, I'm assuming that depending on the direction you pick, the seed you pass 
for the subject or object looks something like this: 
let $seeds as xs:string* := ("urn:1234", "urn:2345", "urn:3456")

Likewise, I assume the same for $filters, but that they are applicable to the 
opposite of the seeds (if direction is true(), then seeds are subjects and 
filters are objects, and vice versa if direction is false()).  Is that correct?

Thanks,
David

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Michael Blakeley
Sent: Wednesday, January 16, 2013 6:53 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Using Semantic library correctly?

Seed values are the starting values for an operation. For example if you want 
to calculate Kevin Bacon's friends to seven generations, the seed value would 
represent Kevin Bacon. There is an example for for sem:transitive-closure() at 
http://marklogic.github.com/semantic/

Does your example do what you want? I think so, but I haven't worked through it 
completely. Another way might two sem:subject-for-predicate() calls, and a map 
operation for the join. That might be faster for a simple case like this.

-- Mike

On 16 Jan 2013, at 11:26 , "Steiner, David J. (LNG-DAY)" 
<[email protected]> wrote:

>  
> Looking into using some tuples in ML, so I want to make sure I am using the 
> functions correctly.  I loaded 721 million tuples, so spot checking results 
> is less than reassuring since results are huge.
>  
> A side note/question: I'm not sure I completely understand the format for 
> "seeds" and neither the reference nor the overview have an example where it 
> is used.  I'm not sure I want to use it just yet, but it would be nice if 
> someone has a better explanation of what a seed would look like for some of 
> the functions that take them.
>  
> At any rate, I've come to the point of where I want to do something like: 
> show me the subjects that have a tuple that has a predicate with value1 and 
> also a tuple with value2.  My current attempt at this is:
>  
> xquery version "1.0-ml";
>  
> import module namespace sem="http://marklogic.com/semantic";
> at "/modules/djs/semantic.xqy";
>  
> let $results := sem:subject-for-join(
>   (sem:object-predicate-join(
>     'this',
>     'predicate1'),
>    sem:object-predicate-join(
>     'that',
>     'predicate2')
> ))
>  
> return
> fn:count($results)
>  
> I've spot checked several of the results (i.e., I get the subjects and look 
> at the tuples for those subjects) and have not come across any that aren't 
> correct (they have both of the predicate-object combos that I've specified).
>  
> For those in the know, am I using these correctly?
>  
> Thanks,
> David
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to