title: Scala: Create all possible permutations of a sentence based synonyms of each word
body: <p>I have a sentence (string) and a function that generates all synonyms of a given word from WordNet. I would like to produce a list of all possible variations of my sentence based on its synonyms. </p>
  
  <p>Furthermore, I would like to maintain the order of the original sentence, meaning permutations should only contain synonyms of the first word as their first word, and permutations of the second word as their second word, etc.</p>
  
  <p>For example, if my input is:</p>
  
  <pre><code>"5 centimeters"
  </code></pre>
  
  <p>My output should be along the lines of:</p>
  
  <pre><code>5 cm
  5 centimetres
  5 centi-meters
  5 centi-metres
  five cm
  five centimetres
  five centi-meters
  five centi-metres
  </code></pre>
  
  <p>What is the best way to proceed with this in Scala? Thanks!</p>