本文整理汇总了Python中sentimentfinding.IOtools.todisc_json方法的典型用法代码示例。如果您正苦于以下问题:Python IOtools.todisc_json方法的具体用法?Python IOtools.todisc_json怎么用?Python IOtools.todisc_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentimentfinding.IOtools
的用法示例。
在下文中一共展示了IOtools.todisc_json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_text_distributions
# 需要导入模块: from sentimentfinding import IOtools [as 别名]
# 或者: from sentimentfinding.IOtools import todisc_json [as 别名]
def get_user_text_distributions(self):
#users = range(1, self.ncoders+1)
# 1- get single-annotation list
# 2- get double-annotation list
usertextassignment = {}
singleannot_distribution = Selection()
singleannot_distribution.initialize(self.months, self.resources, self.cats)
for i,user in enumerate(self.coders):
oneuser_distribution, assignment = self.justice_selection(self.nsingle) # will return textids as (newsid-res-cat) # handle selected_texts here
usertextassignment[i] = assignment
singleannot_distribution.update_selection(oneuser_distribution)
# record userassign. and distribution
#self.singles_jsonpath = os.path.join(self.outfolder, "singleannotation_assignments.txt")
IOtools.todisc_json(self.singles_jsonpath, usertextassignment, ind=5)
singleannot_distribution.todisc(os.path.join(self.outfolder, "singleannotation_distribution.txt"))
textassignments = {}
# BURADA numberofdoubleannotatabletexts sayısında bug var. (self.ncoders/2)*self.noverlaps olmalı.
#doubleannot_distribution, textassignments = self.justice_selection(self.ncoders * self.noverlaps)
doubleannot_distribution, textassignments = self.justice_selection(int(self.ncoders / 2.0) * self.noverlaps)
#self.doubles_jsonpath = os.path.join(self.outfolder, "doubleannotation_assignments.txt")
IOtools.todisc_json(self.doubles_jsonpath, textassignments)
doubleannot_distribution.todisc(os.path.join(self.outfolder, "doubleannotation_distribution.txt"))
示例2: get_user_text_distributions
# 需要导入模块: from sentimentfinding import IOtools [as 别名]
# 或者: from sentimentfinding.IOtools import todisc_json [as 别名]
def get_user_text_distributions(self):
#users = range(1, self.ncoders+1)
# 1- get single-annotation list
# 2- get double-annotation list
usertextassignment = {}
singleannot_distribution = Selection()
singleannot_distribution.initialize(self.months, self.resources, self.cats)
for i,user in enumerate(self.coders):
uid = self.userstartid + i
oneuser_distribution, assignment = self.justice_selection(self.nsingle) # will return textids as (newsid-res-cat) # handle selected_texts here
usertextassignment[uid] = assignment
singleannot_distribution.update_selection(oneuser_distribution)
# record userassign. and distribution
#self.singles_jsonpath = os.path.join(self.outfolder, "singleannotation_assignments.txt")
IOtools.todisc_json(self.singles_jsonpath, usertextassignment, ind=5)
singleannot_distribution.todisc(os.path.join(self.outfolder, "singleannotation_distribution.txt"))
# BURADA numberofdoubleannotatabletexts sayısında bug var. (self.ncoders/2)*self.noverlaps olmalı.
#doubleannot_distribution, textassignments = self.justice_selection(self.ncoders * self.noverlaps)
# ve daha önemli bir bug ortaya çıktı. her pair için ntotaloverlaps kere text alıyor! noverlaps kee almalıydı.
pairtextassignment = {}
doubleannot_distribution = Selection()
doubleannot_distribution.initialize(self.months, self.resources, self.cats)
for i in range(self.userstartid, self.ncoders+self.userstartid ,2):
pair_distribution, assignment = self.justice_selection(self.noverlaps)
pairname = str(i)+"-"+str(i+1)
pairtextassignment[pairname] = assignment
doubleannot_distribution.update_selection(pair_distribution)
#self.doubles_jsonpath = os.path.join(self.outfolder, "doubleannotation_assignments.txt")
IOtools.todisc_json(self.doubles_jsonpath, pairtextassignment, ind=5)
doubleannot_distribution.todisc(os.path.join(self.outfolder, "doubleannotation_distribution.txt"))