def on_uni2zgy_action_activate(self, action, data=None): view = self.window.get_active_view() if view: buff = view.get_buffer() strin = buff.get_property('text') strout = converter.convert(strin, "unicode", "zawgyi") buff.set_text(strout)
def parse_item(self, response): hxs = HtmlXPathSelector(response) paragraphs = hxs.select(r'//p//text()') for paragraph in paragraphs: paragraph = paragraph.extract().strip() paragraph = converter.convert(paragraph, 'zawgyi', 'unicode') if is_large_paragraph(paragraph) and is_mainly_myanmar(paragraph): self.manager.add_item(paragraph)
def parse_item (self, response): hxs = HtmlXPathSelector(response) paragraphs = hxs.select(r"//div//text()") for paragraph in paragraphs: paragraph = paragraph.extract ().strip() paragraph = converter.convert (paragraph, 'zawgyi','unicode') if is_large_paragraph(paragraph) and is_mainly_myanmar(paragraph): self.manager.add_item(paragraph)
def uni2zaw(): m = Frame.m txt = m.get() root20 = tk.Tk() root20.title('Result(2ZawgyiMN)') conv = converter.convert(txt, 'unicode', 'zawgyi') print(conv) pyperclip.copy(conv) label20 = tk.Label(root20, text=conv, font=16) label20.pack(fill="x") root20.mainloop()
def zaw2uni(): m = Frame.m txt = m.get() root19 = tk.Tk() root19.title('Result(2UnicordMN)') conv = converter.convert(txt, 'unicode', 'zawgyi') print(conv) pyperclip.copy(conv) label19 = tk.Label(root19, text=conv, font=16) label19.pack(fill="x") root19.mainloop()
def test_uni2zgy_conversion(): try: path = os.path.join(os.path.dirname(__file__), 'data', 'converter.txt') fil = open(path, 'r', encoding='utf-8') except Exception as e: sys.exit(-1) for line in fil.readlines(): line = line.strip() unistr, zgystr = line.split('\t') assert zgystr == converter.convert(unistr, 'unicode', 'zawgyi') fil.close()
def test_uni2zgy_conversion(): try: path = os.path.join( os.path.dirname(__file__), 'data', 'uni2zgy-conversion.txt' ) fil = open(path, 'r', encoding='utf-8') except Exception as e: sys.exit(-1) for line in fil.readlines(): line = line.strip() unistr, zgystr = line.split('\t') assert zgystr == converter.convert(unistr, 'unicode', 'zawgyi') fil.close()
def zgy_repr (string): zgy_string = converter.convert(string, 'unicode', 'zawgyi') #zfil.write (zgy_string + u'\t\t' + string + u'\n') utf_repr = u' '.join ([repr(c)[3:-1] for c in zgy_string]).replace ("u", "U+").upper () return zgy_string + ' (' + utf_repr + ')'
#!/usr/bin/python import gtk import myanmar.converter as converter clipboard = gtk.clipboard_get() clipboard.set_text(converter.convert(clipboard.wait_for_text(), "zawgyi", "unicode")) clipboard.store()