def process_log(infile, outfile, verbose): # We only need to find the <semitrans> line in each user turn in the file and # append a <semitran_ufal> line with the converted dialogue state. f = open(infile, "r") g = open(outfile, "w") for line in f: isSemitran = re.search(r"([^<]*)<semitran>(.*)</semitran>", line) if isSemitran: whitespace_at_start_of_line = isSemitran.group(1) cued_da = isSemitran.group(2) da = CUEDDialogueAct("", cued_da) # Doesn't need any text. da.parse() ufal_da = da.get_ufal_da() g.write(line) g.write(whitespace_at_start_of_line + "<semitran_ufal>" + ufal_da + "</semitran_ufal>\n") else: g.write(line) f.close() g.close()
def process_log(infile, outfile, verbose): # We only need to find the <semitrans> line in each user turn in the file and # append a <semitran_ufal> line with the converted dialogue state. f = open(infile, 'r') g = open(outfile, 'w') for line in f: isSemitran = re.search(r'([^<]*)<semitran>(.*)</semitran>', line) if isSemitran: whitespace_at_start_of_line = isSemitran.group(1) cued_da = isSemitran.group(2) da = CUEDDialogueAct("", cued_da) # Doesn't need any text. da.parse() ufal_da = da.get_ufal_da() g.write(line) g.write(whitespace_at_start_of_line + "<semitran_ufal>" + ufal_da + "</semitran_ufal>\n") else: g.write(line) f.close() g.close()
print '-' * 120 print 'Input: ' + line text, cued_da = line.split('<=>') text = text.strip() cued_da = cued_da.strip() if verbose: print 'Text: ' + text print 'DA: ' + cued_da print da = CUEDDialogueAct(text, cued_da) da.parse() ufal_da = da.get_ufal_da() if verbose: print 'cued_da: ' + da.get_cued_da() print 'ufal_da: ' + ufal_da ufal_da_list[bnfn].append((da.text, da.get_ufal_da())) da_clustered[da.get_ufal_da()].add(da.text) slts = da.get_slots_and_values() for slt in slts: slots[slt].update(slts[slt]) fo = open( os.path.join(outdir, os.path.basename(fn).replace('.sem', '.grp')), 'w+')
print '-' * 120 print 'Input: ' + line text, cued_da = line.split('<=>') text = text.strip() cued_da = cued_da.strip() if verbose: print 'Text: ' + text print 'DA: ' + cued_da print da = CUEDDialogueAct(text, cued_da) da.parse() ufal_da = da.get_ufal_da() if verbose: print 'cued_da: ' + da.get_cued_da() print 'ufal_da: ' + ufal_da ufal_da_list[bnfn].append((da.text, da.get_ufal_da())) da_clustered[da.get_ufal_da()].add(da.text) slts = da.get_slots_and_values() for slt in slts: slots[slt].update(slts[slt]) fo = open(os.path.join( outdir, os.path.basename(fn).replace('.sem', '.grp')), 'w+') for key in sorted(da_clustered):