The query at the bottom of this post returns a collection of what I call paths, but you might call vertex sets as shown in the screenshot below. Question. What’s the correct term for these?
Based on the logic we came up with thus far I can return vertex sets that make up phrases like this:
“during any period of construction to a width”
This was the easy part. Now I need to do additional processing on each phrase. The last vertex is “width” which I have the vertex id to use. I need to look n hops past this vertex looking for a word such as “100” or “one hundred” followed by another vertex 1 or 2 more hops containing the text:
(feet|foot|meter|inches|inch|’|”)
Note: In the example above the text “one hundred” will actually be a combination of 2 vertices.
If I can find the correct words (match the criteria correctly), then I need to add the word from each hop to the end of the phrase. This should give us a finished phrase like:
“during any period of construction to a width of (100) feet”
I’m thinking we can use a UDFs with regex for parts of this. The first question in this puzzle is how do we break the accumulator values down to these subsets and begin the additional processing.
Thank you.
CREATE QUERY aFindPathContainingMulitCriteria(STRING criteria, INT maxDist) FOR GRAPH MyGraph {
/* exclusive,permanent,Right,Way */
ListAccum<string> @@criteriaWords;
SetAccum<edge> @@edgeSet;
SetAccum<vertex> @@vSet;
ListAccum<STRING> @@words;
STRING startWord;
STRING endWord;
INT wordCount;
@@criteriaWords += string_split(criteria,",");
startWord = @@criteriaWords.get(0);
endWord = @@criteriaWords.get(@@criteriaWords.size()-1);
Start (ANY) = {word.*};
Start = select s from Start:s where s.Text == startWord;
while Start.size() > 0 limit 20 do
Start = select t from Start:s-(nextword:e)-word:t
accum @@edgeSet += e,
@@vSet += t,
@@words += t.Text
having t.Text != endWord;
end;
vSet = @@vSet;
print @@vSet,@@edgeSet, vSet;
print @@words;
}