예제 #1
0
def write(glos, filename):
    fp = open(filename, 'wb')
    fp.write('<?xml version="1.0" encoding="utf-8" ?>\n<words>\n<xfardic>')
    for item in infoKeys:
        fp.write('<'+item+'>'+str(glos.getInfo(item))+'</'+item+'>')
    fp.write('</xfardic>\n')
    for entry in glos:
        words = entry.getWords()
        word, alts = words[0], words[1:]
        defi = entry.getDefi()
        #fp.write("<word><in>"+word+"</in><out>"+ defi+"</out></word>\n")
        fp.write('<word>\n    <in>%s</in>\n'%escape(word))
        for alt in alts:
            fp.write('    <alt>%s</alt>\n'%escape(alt))
        fp.write('    <out>%s</out>\n</word>\n'%escape(defi))
    fp.write("</words>\n")
    fp.close()
예제 #2
0
def write(glos, filename):
    fp = open(filename, 'wb')
    fp.write('<?xml version="1.0" encoding="utf-8" ?>\n<words>\n<xfardic>')
    for item in infoKeys:
        fp.write('<' + item + '>' + str(glos.getInfo(item)) + '</' + item +
                 '>')
    fp.write('</xfardic>\n')
    for entry in glos:
        words = entry.getWords()
        word, alts = words[0], words[1:]
        defi = entry.getDefi()
        #fp.write("<word><in>"+word+"</in><out>"+ defi+"</out></word>\n")
        fp.write('<word>\n    <in>%s</in>\n' % escape(word))
        for alt in alts:
            fp.write('    <alt>%s</alt>\n' % escape(alt))
        fp.write('    <out>%s</out>\n</word>\n' % escape(defi))
    fp.write("</words>\n")
    fp.close()
예제 #3
0
def write(glos, filename):
    fp = open(filename, 'wb')
    fp.write('<?xml version="1.0" encoding="utf-8" ?>\n<words>\n<xfardic>')
    for item in infoKeys:
        fp.write('<'+item+'>'+str(glos.getInfo(item))+'</'+item+'>')
    fp.write('</xfardic>\n')
    for item in glos.data:
        #fp.write("<word><in>"+item[0]+"</in><out>"+ item[1]+"</out></word>\n")
        fp.write('<word>\n    <in>%s</in>\n'%escape(item[0]))
        try:
            alts = item[2]['alts']
        except:
            pass
        else:
            for alt in alts:
                fp.write('    <alt>%s</alt>\n'%escape(alt))
        fp.write('    <out>%s</out>\n</word>\n'%escape(item[1]))
    fp.write("</words>\n")
    fp.close()
예제 #4
0
def write(glos, filename):
    fp = open(filename, 'wb')
    fp.write('<?xml version="1.0" encoding="utf-8" ?>\n<words>\n<xfardic>')
    for item in infoKeys:
        fp.write('<' + item + '>' + str(glos.getInfo(item)) + '</' + item +
                 '>')
    fp.write('</xfardic>\n')
    for item in glos.data:
        #fp.write("<word><in>"+item[0]+"</in><out>"+ item[1]+"</out></word>\n")
        fp.write('<word>\n    <in>%s</in>\n' % escape(item[0]))
        try:
            alts = item[2]['alts']
        except:
            pass
        else:
            for alt in alts:
                fp.write('    <alt>%s</alt>\n' % escape(alt))
        fp.write('    <out>%s</out>\n</word>\n' % escape(item[1]))
    fp.write("</words>\n")
    fp.close()