本文整理匯總了Python中reverend.thomas.Bayes.poolNames方法的典型用法代碼示例。如果您正苦於以下問題:Python Bayes.poolNames方法的具體用法?Python Bayes.poolNames怎麽用?Python Bayes.poolNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類reverend.thomas.Bayes
的用法示例。
在下文中一共展示了Bayes.poolNames方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Trainer
# 需要導入模塊: from reverend.thomas import Bayes [as 別名]
# 或者: from reverend.thomas.Bayes import poolNames [as 別名]
class Trainer(Frame):
def __init__(self, parent, guesser=None, itemClass=None):
self.status = StatusBar(parent)
self.status.pack(side=BOTTOM, fill=X)
Frame.__init__(self, parent)
self.pack(side=TOP, fill=BOTH)
self.itemsPerPage = 20
self.rows = []
for i in range(self.itemsPerPage):
self.rows.append(ItemRow())
self.items = []
self.files = []
self.cursor = 0
self.dirty = False
if guesser is None:
from reverend.thomas import Bayes
self.guesser = Bayes()
else:
self.guesser = guesser
if itemClass is None:
self.itemClass = TextItem
else:
self.itemClass = itemClass
for row in self.rows:
row.summary.set('foo')
self.initViews()
def initViews(self):
self.nb = Notebook(self)
## frame1 = Frame(self.nb())
## self.poolView = PoolView(frame1, guesser=self.guesser, app=self)
## self.poolView.pack(side=TOP)
frame2 = Frame(self.nb())
self.poolView = PoolView(frame2, guesser=self.guesser, app=self)
self.poolView.pack(side=TOP)
self.listView = Canvas(frame2, relief=GROOVE)
self.listView.pack(padx=3)
bn = Button(self.listView, text="Load training", command=self.loadCorpus)
bn.pack(side=RIGHT, anchor=NE, fill=X)
self.columnHeadings()
self.addNextPrev()
frame3 = Frame(self.nb())
self.testView = TestView(frame3, guesser=self.guesser, app=self)
self.testView.pack()
frame4 = Frame(self.nb())
bp = Button(frame4, text="Quit", command=self.quitNow)
bp.pack(side=BOTTOM)
#self.nb.add_screen(frame1, 'Reverend')
self.nb.add_screen(frame2, 'Training')
self.nb.add_screen(frame3, 'Testing')
self.nb.add_screen(frame4, 'Quit')
def addNextPrev(self):
npFrame = Frame(self.listView)
npFrame.pack(side=BOTTOM, fill=X)
bn = Button(npFrame, text="Prev Page", command=self.prevPage)
bn.grid(row=0, column=0)
bn = Button(npFrame, text="Next Page", command=self.nextPage)
bn.grid(row=0, column=1)
def loadCorpus(self):
path = tkFileDialog.askdirectory()
if not path:
return
self.loadFileList(path)
self.displayItems()
self.displayRows()
def bulkTest(self):
dirs = []
for pool in self.guesser.poolNames():
path = tkFileDialog.askdirectory()
dirs.append((pool, path))
for pool, path in dirs:
print pool, path
def displayList(self):
for item in self.items:
self.itemRow(item)
def displayRows(self):
for row in self.rows:
self.displayRow(row)
def loadFileList(self, path):
listing = os.listdir(path)
self.files = [os.path.join(path, file) for file in listing]
self.cursor = 0
def prevPage(self):
self.cursor = max(0, self.cursor - self.itemsPerPage)
self.displayItems()
def nextPage(self):
#.........這裏部分代碼省略.........