Created
May 19, 2016 07:32
-
-
Save ableasdale/ce77d1cc1b3dff949f744f92b21dce80 to your computer and use it in GitHub Desktop.
Simple stopwords example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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