title: Implementing a synonym search with javascript
body: <p>I'm using pdfjs to loop through some pdfs and run searches for some search terms. At the moment if a match is found the line containing the search term is returned and stored in an array of objects. I now need add another functionality to the search, and implement some kind of synonym search, so that if a match is found not only it will return the line containing the match but also the lines containing synonyms of the match. I've done a bit of googling but I didn't come across anything that relevant. I've got no idea what this involves - well presumably some kind of array where I can store search terms and synonyms - so I was wondering if anybody could give me an idea or any suggestion? thanks</p>
  
  <p>EDIT:
  Right, after what you guys have said, if I run a smaller scale search, this is what I was thinking to do:
  -Create an array of search terms and synonyms, like so</p>
  
  <pre><code>var arrayOfWords = [];
  arrayOfWords[
      {
          "SearchTerm":"mySearchTerm1",
          "Syn":"synonym1",
          "Syn":"synonym2",
          "Syn":"synonym3"
      },
      {
          "SearchTerm":"mySearchTerm2",
          "Syn":"synonym1",
          "Syn":"synonym2",
          "Syn":"synonym3"
      }   
  ]
  </code></pre>
  
  <p>And then this is what I envisage could happen:</p>
  
  <pre><code>when a search term is chosen, 
      check if it's in the array (under SearchTerms)
          if so
              run a search with that search term
                  get results in array of results
              get first synonym
                  run a search with the synonym
                      get results in array of results
              get second synonym
                  ...
          print array of objects
  </code></pre>