Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created May 19, 2016 07:32
Show Gist options
  • Save ableasdale/ce77d1cc1b3dff949f744f92b21dce80 to your computer and use it in GitHub Desktop.
Save ableasdale/ce77d1cc1b3dff949f744f92b21dce80 to your computer and use it in GitHub Desktop.
Simple stopwords example
xquery version "1.0-ml";
(: imagine this is a string from an input field :)
declare variable $STRING as xs:string := "the quick brown fox jumped over the lazy dog";
(: this would be a comprehensive list of words they want to exclude from any searches to improve relevance/scoring etc :)
declare variable $STOPWORD-LIST as xs:string+ := ("the");
let $searchable-tokens := for $token in fn:tokenize($STRING, " ")
return if(some $word in $STOPWORD-LIST satisfies ($token eq $word))
then((: it's a stopword, so we don't return it :))
else($token)
return $searchable-tokens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment