class CleanserWebService(): def __init__(self): self.tc = TextCleanser() @expose def clean(self, text): cleantext, error, replacements = self.tc.ssk_cleanse(text) if error == "": return cleantext else: # an error occurred return error
class CleanserWebService(): def __init__(self): self.tc = TextCleanser() @expose def clean(self, text): cleantext, error, replacements = self.tc.ssk_cleanse(text) if error=="": return cleantext else: # an error occurred return error
import sys, time from random import choice if __name__ == '__main__': # print "Noisy text cleanser" clnsr = TextCleanser() text = sys.stdin.readline() while (text): if len(text) <= 1: break # cleantext,error,replacements = clnsr.heuristic_cleanse(text, gen_off_by_ones=False) # to use a phonetic edit-distance based similarity function, use the # method below: # cleantext,error,replacements = clnsr.phonetic_ED_cleanse(text, gen_off_by_ones=False) # to use SSK-based cleanser, use cleantext, error, replacements = clnsr.ssk_cleanse( text, gen_off_by_ones=False) if error == "ERROR": sys.stderr.write("ERROR") continue else: sys.stdout.write(cleantext) # need to flush the output buffers so that the java wrapper can read in the input sys.stdout.flush() sys.stderr.flush() text = sys.stdin.readline()
import sys, time from random import choice if __name__ == '__main__': # print "Noisy text cleanser" clnsr = TextCleanser() text=sys.stdin.readline() while (text): if len(text)<=1: break # cleantext,error,replacements = clnsr.heuristic_cleanse(text, gen_off_by_ones=False) # to use a phonetic edit-distance based similarity function, use the # method below: # cleantext,error,replacements = clnsr.phonetic_ED_cleanse(text, gen_off_by_ones=False) # to use SSK-based cleanser, use cleantext,error,replacements = clnsr.ssk_cleanse(text, gen_off_by_ones=False) if error=="ERROR": sys.stderr.write("ERROR") continue else: sys.stdout.write(cleantext) # need to flush the output buffers so that the java wrapper can read in the input sys.stdout.flush() sys.stderr.flush() text=sys.stdin.readline()