daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. from ngram.Distance import edit_distance
  3.  
  4. def get_min_distance_alternate( pizhai ):
  5.     agarathi_sorkal = [u'அவிழ்',u'அவல்',u'அவள்',u'தவில்',u'தவள்']
  6.     distances = map( lambda w: edit_distance( pizhai, w) , agarathi_sorkal )
  7.     print(distances)
  8.     m = min(distances)
  9.     idx = -1
  10.     matches = []
  11.     while True:
  12.         old_idx = idx
  13.         try:
  14.             idx = distances.index(m,1+old_idx,len(distances))
  15.         except ValueError:
  16.             break
  17.         matches.append( agarathi_sorkal[idx] )
  18.     return matches
  19.  
  20. pizhai_sorkal = [u'ஏவள்', u'இவல்']
  21. for pizhai in pizhai_sorkal:
  22.     alternate = get_min_distance_alternate( pizhai )
  23.     print(u"%s => %s"%(pizhai,u",".join(alternate)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top