Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Isn't the key that specificity decreases from left to right? That is, the right-most semantic element (whether "New York" or "Manhattan") is always the least-specific (if it's a Borough, then we don't have to worry about City, if it's a Street, we don't have to worry about Borough, etc.) </p> <p>So reverse the tokens and recurse through, seeking either a complete hit ("Manhattan") or a keyword ("Avenue", "Street", "New") that indicates either the beginning or end of a semantic element. So after a pass, you might have:</p> <pre><code>"5th Avenue" -&gt; TOKEN STREET_END_TOKEN "Manhattan" -&gt; BOROUGH "New York" -&gt; COMPOUND_BEGIN_TOKEN TOKEN "5th Avenue Manhattan" -&gt; TOKEN STREET_END_TOKEN BOROUGH "5th Avenue Manhattan New York" -&gt; TOKEN STREET_END_TOKEN BOROUGH COMPOUND_BEGIN_TOKEN TOKEN "Manhattan New York" -&gt; BOROUGH COMPOUND_BEGIN_TOKEN TOKEN "5th Avenue New York" -&gt; TOKEN STREET_END_TOKEN COMPOUND_BEGIN_TOKEN TOKEN </code></pre> <p>Which ought to give you enough to pattern-match against.</p> <p>UPDATE:</p> <p>OK, to expand on the general strategy:</p> <pre><code>Step 1 : Generate a pattern of the query structure by identifying keywords ("Manhattan"), and semantically-meaningful ("Street", "Avenue") or grammatically-significant ("New", "Saint") tokens. Step 2: Match the generated pattern against a set of templates -- "* BOROUGH *" -&gt; (Street) (BOROUGH) (City)", "* STREET_END_TOKEN" -&gt; (Street name) (Street type), etc. Step 3: The result of Step 2 ought to give you a sense of what kind of query you're dealing with. You'll have to apply domain rules at that point (if you know the complete query is TOKEN STREET_END_TOKEN then you know "Well, this is a query that just specifies a street" and you have to apply whatever rule is appropriate (grab the locale of their browser? Use their query history to guess which neighborhood and city? etc.) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload