title: I have an array of strings; is there a way to see which one an argument string is closest to?
body: <p>I'm working in Python, and I've decided to break down and make a huge array of phrases for the result of a speech recognition module to compare to. So far I've got:</p>
  
  <pre><code>phrases = [
      "what time is it",
      "what's the weather",
      "what's the date",
      "hello",
      "hi",
      "what's up",
      "how are you"
  ]
  </code></pre>
  
  <p>(I've only just started this a few minutes ago, so I haven't got much yet... Mostly just an outline) But anyway, I'd like a function kind of like this...</p>
  
  <pre><code>def match(phrase):
      #match_greatest will start at zero but continuously update if the string
      #being compared has a higher percentage match
      match_greatest = 0
  
      #match will store the actual string that is closest
      match = ""
  
      for i in phrases:
          #this is the part I need help with...
          match_current = #somehow get the percentage that the argument phrase matches the phrase it's comparing to
  
          #if the current phrase is a closer match than before, update it
          if match_current &gt; match_greatest:
              match_greatest = match_current
              match = i
  
      return match
  </code></pre>
  
  <p>...so as an example, if I call match("what time it a") or match("what time sit") -- these are examples of a misreading that the speech recognition could give -- and use my current set of phrases, it would return "what time is it".</p>