Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // в getPatterns на самом деле из конфига такого вида:
- //
- // "улица" : ["у","ул","ули","улиц","ул-ца"]
- //
- // получаем список пар ("rexex", "полная форма")
- def = List(
- ("(?iu)у", "улица"),
- ("(?iu)ул", "улица"),
- ("(?iu)ул-ца", "улица")
- )
- // раскрываем сокращения
- def expose(query: String) = {
- var output: String = query
- for {
- pattern <- getPatterns().sortBy(x => -x._1.length).
- } output = pattern._1.r.replaceAllIn(output, " "+pattern._2)
- output.replaceAll("\\s{2,}"," ")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement