juan_gandhi: (VP)
[personal profile] juan_gandhi
object DoggyEnglish {
  val meaningless = Set("name", "of", "the", "my", "your", "in", "what", "which", "was", "is")

  val synonyms = Set("city, town", "sibling, siblings", "job, work") .map {
    word => word.split(", ").toList
  } .collect {
    case main::tail => tail map (w => w -> main)
  } .flatten .toMap withDefault identity


  def simplifyQuestion(question: String) = {
    val noPunctuation = question.toLowerCase.replaceAll("[^a-z ]", "")
    val words = noPunctuation split " "
    val meaningfulWords = words filterNot meaningless
    val standardized = meaningfulWords map synonyms
    standardized mkString " "
  }

}
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 20th, 2025 04:24 pm
Powered by Dreamwidth Studios