def printkovtreylyans(): """ show the output in Cornish, according to the options in the radiobar is selected """ allstates() inputtext = ent.gettext() print("Input: {i}".format(i=inputtext)) output = '' msg3.text.config(fg='dark red', bg='light yellow', font=('Courier', 14 + fontsizeadj, 'normal'), state=tk.NORMAL) if inputtext: if options.state() == 'All trigrams and bigrams': output = kovtreylyans.kovtreyl(inputtext, skeulanyeth1, False, allNgrams=True, linelength=outputwidth - 2) msg3.text.config(font=('Courier', 12 + fontsizeadj, 'normal')) else: # show only N grams containing non stopwords output = kovtreylyans.kovtreyl(inputtext, skeulanyeth1, False, allNgrams=False, linelength=outputwidth - 2) output = wraplines(output, wline) # print(output) msg3.settext(output) msg3.text.config(state=tk.DISABLED)
def printsylranna(): """ show the output in Welsh, according to the options in the radiobar is selected """ allstates() inputtext = ent.gettext() print("Input: {i}".format(i=inputtext)) output = '' msg3.text.config(fg = 'dark red', bg = 'light yellow', font=('Open Sans', 16+fontsizeadj, 'bold'), state=tk.NORMAL) if inputtext: # standardise quote characters etc. inputtext = syl.preprocess2ASCII(inputtext) if options2.state() == 'Rhannu ymlaen': fwd = True else: fwd = False regexps=syl.cyRegExp if options.state() == 'Mode Hir': output = syl.detailSylsText(inputtext, fwd, regexps=regexps, FSSmode=False, CYmode=True, gwarnya=rhybudd.state()[0]) # long mode doesn't normally need word wrapping, but just in case # someone enters Llan50goch in full output=wraplines(output) msg3.text.config(font=('Open Sans', 14+fontsizeadj, 'normal'), width=66, height=12+heightadjust) elif options.state() == 'Mode Llinell': msg3.text.config(font=('Open Sans', 16+fontsizeadj, 'bold'), width=60, height=11+heightadjust) lines = inputtext.split('\n') for l in lines: output += syl.countSylsLine(l, fwd, regexps=regexps, FSSmode=False, CYmode=True, gwarnya=rhybudd.state()[0])+'\n\n' output = wraplines(output) else: msg3.text.config(font=('Open Sans', 16+fontsizeadj, 'bold'), width=60, height=11+heightadjust) # use short mode by default if nothing is selected output = syl.detailSylsText(inputtext, fwd, short=True, regexps=regexps, FSSmode=False, CYmode=True, gwarnya=rhybudd.state()[0]) output = textwrap.fill(output, 60) print(output) msg3.settext(output) msg3.text.config(state=tk.DISABLED)
def printtreus(): """ show the output in Cornish, according to the options in the radiobar is selected """ allstates() inputtext = ent.gettext() print("Input: {i}".format(i=inputtext)) output = '' msg3.text.config(fg='dark red', bg='light yellow', font=('Open Sans', 16 + fontsizeadj, 'bold'), state=tk.NORMAL) if inputtext: inputtext = preprocess2ASCII(inputtext) if options2.state() == 'Rannans war-rag': fwd = True else: fwd = False if options.state() == 'Mode Hir': output = tr.text_KK2FSS(inputtext, fwd, longform=True) output = wraplines(output) msg3.text.config(font=('Open Sans', 14 + fontsizeadj, 'normal'), width=66, height=12 + heightadjust) elif options.state() == 'Mode Linenn' or options.state( ) == 'Mode Berr': msg3.text.config(font=('Open Sans', 16 + fontsizeadj, 'bold'), width=60, height=11 + heightadjust) lines = inputtext.split('\n') for l in lines: if options.state() == 'Mode Linenn': output += tr.line_KK2FSS(l, fwd) + '\n\n' else: output += tr.line_KK2FSS(l, fwd, longform=False) + '\n' output = wraplines(output) print(output) msg3.settext(output) msg3.text.config(state=tk.DISABLED)
def printtermyn(): """ show the time or date in Cornish according to the preferences in the checkboxes """ allstates() dydh, blydh, niver, nes, kewar, gor = options.state() output = "" timenow = time.localtime() if dydh: if blydh: output += termyn.dydhyas(timenow, blydhen=True) else: output += termyn.dydhyas(timenow, blydhen=False) output += "\n" else: if blydh: output += niverow.numberkw(timenow.tm_year) + "\n" if niver: output += "{h:02d}:{m:02d}\n".format(h=timenow.tm_hour, m=timenow.tm_min) if nes: output += termyn.termyn_approx(timenow.tm_hour, timenow.tm_min) + "\n" if kewar: output += termyn.termyn_exact(timenow.tm_hour, timenow.tm_min) + "\n" if gor: g = gorhemmyn.Gorhemmyn() output += g.gorhemmyn try: # wrap in try in case espeak doesn't exist g.kewsel() except: pass wrapoutput = wraplines(output, 50) print(wrapoutput) msg3.config(fg='dark red', bg='light yellow', font=('Open Sans', 18, 'bold'), text=wrapoutput)
def printsylranna(): """ show the output in Cornish, according to the options in the radiobar is selected """ allstates() inputtext = ent.gettext() print("Input: {i}".format(i=inputtext)) output = '' msg3.text.config(fg='dark red', bg='light yellow', font=('Open Sans', 16, 'bold'), state=tk.NORMAL) if inputtext: # standardise quote characters etc. inputtext = syl.preprocess2ASCII(inputtext) if options2.state() == 'Rannans war-rag': fwd = True else: fwd = False if kkfss.state() == 'Kernewek FSS': regexps = syl.kwFSSRegExp FSS = True else: regexps = syl.kwKemmynRegExp FSS = False if options.state() == 'Mode Hir': output = syl.detailSylsText(inputtext, fwd, regexps=regexps, FSSmode=FSS, gwarnya=gwarnya.state()[0]) # only needed in cases of very long words output = wraplines(output) msg3.text.config(font=('Open Sans', 14, 'normal'), width=66, height=12 + heightadjust) elif options.state() == 'Mode Linenn': msg3.text.config(font=('Open Sans', 16, 'bold'), width=60, height=11 + heightadjust) lines = inputtext.split('\n') for l in lines: output += syl.countSylsLine( l, fwd, regexps=regexps, FSSmode=FSS, gwarnya=gwarnya.state()[0]) + '\n\n' output = wraplines(output) else: msg3.text.config(font=('Open Sans', 16, 'bold'), width=60, height=11 + heightadjust) # use short mode by default if nothing is selected output = syl.detailSylsText(inputtext, fwd, short=True, regexps=regexps, FSSmode=FSS, gwarnya=gwarnya.state()[0]) output = textwrap.fill(output, 60) print(output) msg3.settext(output) msg3.text.config(state=tk.DISABLED)
def printoutput(self): """ show the output """ if self.modechoice.state() == 0: topN = self.getIntMinL(self.ent2.fetch(), 20) minL = self.getIntMinL(self.ent.fetch(), 4) if self.textchoice.state() == 11: outputtext = cornish_corpus.basicReportAll( self.kk_texts, self.names, topN, minL, pause=False, outlang=self.ifacelang) else: outputtext = cornish_corpus.basicReport( self.kk_text_dict[self.names[self.textchoice.state()]], self.names[self.textchoice.state()], topN, minL, outlang=self.ifacelang) outputtext = wraplines(outputtext, self.wline) self.outbox.settext(outputtext) if self.modechoice.state() == 1: # rol menowghder ger topN = self.getIntMinL(self.ent2.fetch(), 20) minL = self.getIntMinL(self.ent.fetch()) if self.textchoice.state() == 11: self.outbox.settext( cornish_corpus.MostFrequentWords(self.kk_texts, self.names, topN, minL, outlang=self.ifacelang)) else: self.outbox.settext( cornish_corpus.MostFreqWords1Text( self.kk_text_dict[self.names[self.textchoice.state()]], self.names[self.textchoice.state()], topN, minL, outlang=self.ifacelang)) if self.modechoice.state() == 2: if self.textchoice.state() == 11: self.outbox.settext( cornish_corpus.MostFreqLetters(self.kk_texts, self.names, outlang=self.ifacelang)) else: self.outbox.settext( cornish_corpus.MostFreqLetters1Text( self.kk_text_dict[self.names[self.textchoice.state()]], self.names[self.textchoice.state()], outlang=self.ifacelang)) if self.modechoice.state() == 3: if self.textchoice.state() == 11: self.outbox.settext( cornish_corpus.MostFreqLetters(self.kk_texts, self.names, False, False, outlang=self.ifacelang)) else: self.outbox.settext( cornish_corpus.MostFreqLetters1Text( self.kk_text_dict[self.names[self.textchoice.state()]], self.names[self.textchoice.state()], False, False, outlang=self.ifacelang)) if self.modechoice.state() == 4: plt.figure() if self.textchoice.state() == 11: self.outbox.settext( cornish_corpus.nLettersFDist(self.kk_texts, self.names, outlang=self.ifacelang)) else: self.outbox.settext( cornish_corpus.nLettersFDist([ self.kk_text_dict[self.names[self.textchoice.state()]] ], [self.names[self.textchoice.state()]], outlang=self.ifacelang)) plt.show() if self.modechoice.state() == 5: plt.figure() comparelist = self.getcomparelist() if len(comparelist) == 0: comparelist = self.defaultsamples self.outbox.text.config(bg='light yellow', fg='dark red', font=('Courier', 12 + self.fontsizeadj, 'normal')) if self.textchoice.state() == 11: outputtext = str(comparelist)+'\n\n'+ \ cornish_corpus.compareSamples(self.kk_texts, self.names, comparelist, outlang=self.ifacelang) else: outputtext = str(comparelist)+'\n\n'+ \ cornish_corpus.compareSamples([ self.kk_text_dict[self.names[self.textchoice.state()]]], [self.names[self.textchoice.state()]], comparelist, outlang=self.ifacelang) outputtext = wraplines(outputtext, self.wline) self.outbox.settext(outputtext) plt.show() if self.modechoice.state() == 6: comparelist = self.getcomparelist() if len(comparelist) == 0: comparelist = self.defaultsamples self.outbox.text.config(bg='light yellow', fg='dark red', font=('Courier', 12 + self.fontsizeadj, 'normal')) if self.textchoice.state() == 11: outputtext = str(comparelist)+'\n\n'+ \ cornish_corpus.compareSamplesLinear( self.kk_texts, self.names, comparelist, outlang=self.ifacelang) else: outputtext = str(comparelist)+'\n\n'+ \ cornish_corpus.compareSamplesLinear( [self.kk_text_dict[self.names[self.textchoice.state()]]], [self.names[self.textchoice.state()]], comparelist, outlang=self.ifacelang) outputtext = wraplines(outputtext, self.wline) self.outbox.settext(outputtext) plt.show() if self.modechoice.state() == 7: comparelist = self.getcomparelist() if len(comparelist) == 0: comparelist = ['dhe', 'gans'] self.outbox.text.config(bg='light yellow', fg='dark red', font=('Courier', 10 + self.fontsizeadj, 'normal')) if self.textchoice.state() == 11: outputtext = str(comparelist)+'\n\n'+ \ cornish_corpus.concordances( self.kk_texts, self.names, comparelist, 59, 25, outlang=self.ifacelang) else: outputtext = str(comparelist)+'\n\n'+ \ cornish_corpus.concordances( [self.kk_text_dict[self.names[self.textchoice.state()]]], [self.names[self.textchoice.state()]], comparelist, 59,25, outlang=self.ifacelang) outputtext = wraplines(outputtext, self.wline) self.outbox.settext(outputtext) if self.modechoice.state() == 8: comparelist = self.getcomparelist() regexlist = [ "<.*><.*><.*><.*><a><vynn><.*><.*><.*>", "<.*><.*><.*><.*><a><wra><.*><.*><.*>", "<.*><.*><.*><y><fynn.*><.*><.*><.*>", "<.*><.*><.*><y><hwr.*><.*><.*><.*>" ] # find any comparelist items which begin and end in angle brackets comparelist = [ c for c in comparelist if (c[0] == "<" and c[-1] == ">") ] if len(comparelist) > 0: regexlist = comparelist self.outbox.text.config(bg='light yellow', fg='dark red', font=('Courier', 10 + self.fontsizeadj, 'normal')) if self.textchoice.state() == 11: outputtext = str( regexlist) + '\n\n' + cornish_corpus.findallRegex( self.kk_texts, self.names, regexlist, outlang=self.ifacelang) else: outputtext = str( regexlist ) + '\n\n' + cornish_corpus.findallRegex( [self.kk_text_dict[self.names[self.textchoice.state()]]], [self.names[self.textchoice.state()]], regexlist, outlang=self.ifacelang) outputtext = outputtext.replace("; ", "\n\n") outputtext = wraplines(outputtext, self.wline) self.outbox.settext(outputtext)