本文整理汇总了Python中datamodel.DataModel.judged_documents方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.judged_documents方法的具体用法?Python DataModel.judged_documents怎么用?Python DataModel.judged_documents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datamodel.DataModel
的用法示例。
在下文中一共展示了DataModel.judged_documents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CWR
# 需要导入模块: from datamodel import DataModel [as 别名]
# 或者: from datamodel.DataModel import judged_documents [as 别名]
#.........这里部分代码省略.........
'''
Updates the worker rationale list. If one or more worker IDs is
selected, this will display only the rationales by the selected
workers. Otherwise, this will display all rationales for the
selected Topic and Document.
'''
display_text = ''
selected = [r for r in self._rationales if r.display.isChecked()]
# If none are selected, display all.
selected = selected if selected else self._rationales
for r in selected:
display_text += ('%s\n\n%s\n\n' % (r.rationale.label, r.rationale.rationale.rationale))
self._worker_rationales.setText(display_text)
def update_judgment_list(self, topic=None, document=None):
'''
Updates the worker judgment list. If one or more worker IDs is
selected, this will display only the judgments of those selected
workers. Otherwise, this will display the judgments from all workers.
'''
display_text = ''
selected = [r for r in self._rationales if r.display.isChecked()]
# If none are selected, display all.
selected = selected if selected else self._rationales
for r in selected:
display_text += ('%s: %s\n' % (r.rationale.label, r.rationale.rationale.value))
self._worker_judgments.setText(display_text)
def update_rationale_text(self, text):
'''
This updates the text in the rationale display.
'''
self._rationale_display.set_text(text)
def highlight_rationale(self, text):
self._rationale_display.highlight(text)
def load_document(self, url):
self._rationale_display.load(QUrl(url))
#########################################################################################
# Signals #
#########################################################################################
def _topic_selected(self, item):
'''
Handler function - user selects a topic in the Topic View.
Refreshes the list of documents in the Document View with
all documents for which a worker judgment has been loaded
for that topic. Computes statistics across that topic.
'''
topic_id = item.text()
# Update control selection.
self._selected_topic = topic_id
# Update statistics view.
self.update_statistics(topic=str(topic_id))
print ("Loading documents for topic %s" % topic_id)
documents = self._dm.judged_documents_by_topic(topic_id)
self.update_document_list([d.id for d in documents])
def _document_selected(self, item):
'''
Handler function - user select a document in the Document View.
Loads the text from that document into the rationale display
and computes statistics for that document.
'''
document_id = item.text()
# Update control selection.
self._selected_document = document_id
# Grab control selections.
selected_topic = self._selected_topic
selected_document = self._selected_document
print ("Loading rationales for document %s, topic %s" % (selected_document, selected_topic))
rationales = self._dm.judgments(selected_topic, selected_document)
rationales = [Rationale(str(random.randint(1,10000)), r) for r in rationales]
self.update_rationale_selection(rationales)
# Update statistics view.
self.update_statistics(str(selected_topic), str(selected_document))
# Load document.
document = next((d for d in self._dm.judged_documents() if d.id == selected_document), None)
self.load_document(document.url)
def _rationale_selection_changed(self, state):
'''
Handler function called when a user selects or deselects a rationale
check box.
'''
worker = Thread(target=self.update_rationale_display)
worker.start()