本文整理汇总了Python中sentimentfinding.IOtools.todisc_freqdist方法的典型用法代码示例。如果您正苦于以下问题:Python IOtools.todisc_freqdist方法的具体用法?Python IOtools.todisc_freqdist怎么用?Python IOtools.todisc_freqdist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentimentfinding.IOtools
的用法示例。
在下文中一共展示了IOtools.todisc_freqdist方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: diff_word_lists
# 需要导入模块: from sentimentfinding import IOtools [as 别名]
# 或者: from sentimentfinding.IOtools import todisc_freqdist [as 别名]
def diff_word_lists(list1, list2, outdir, outfilename):
l = list(set(list1) - set(list2))
IOtools.todisc_list(outdir+os.sep+outfilename+".txt", l)
fdist = nltk.FreqDist(l)
IOtools.todisc_freqdist(outdir+os.sep+"weighted-"+outfilename+".txt", fdist)
return l
示例2: get_label_counts
# 需要导入模块: from sentimentfinding import IOtools [as 别名]
# 或者: from sentimentfinding.IOtools import todisc_freqdist [as 别名]
def get_label_counts(annottype, agreementtype, labelrootfolder=metacorpus.annotatedrootpath, statsfolder=metacorpus.annotationstatsfolder):
dfpath = metacorpus.get_annotatedtexts_file_path(annottype, agreementtype)
labeldf = IOtools.readcsv(dfpath)
#nrows, _ = labeldf.shape
labeldist = FreqDist(labeldf["answer"].values.tolist())
outpath = os.path.join(statsfolder, annottype+"_"+agreementtype+"-labeloccurrences.csv")
IOtools.todisc_freqdist(outpath, labeldist)
示例3: merge_word_lists
# 需要导入模块: from sentimentfinding import IOtools [as 别名]
# 或者: from sentimentfinding.IOtools import todisc_freqdist [as 别名]
def merge_word_lists(indirectory, outdirectory, outfilename):
fileids = IOtools.getfilenames_of_dir(indirectory, removeextension=False)
allwords = []
for fileid in fileids:
words = IOtools.readtextlines(indirectory+os.sep+fileid)
allwords.extend(words)
IOtools.todisc_list(outdirectory+os.sep+outfilename+".txt", allwords)
fdist = nltk.FreqDist(allwords)
IOtools.todisc_freqdist(outdirectory+os.sep+"weighted-"+outfilename+".txt", fdist)
'''
示例4: intersect_word_lists
# 需要导入模块: from sentimentfinding import IOtools [as 别名]
# 或者: from sentimentfinding.IOtools import todisc_freqdist [as 别名]
def intersect_word_lists(list1, list2, outdir, outfilename):
intersect = []
allwords = []
allwords.extend(list1)
allwords.extend(list2)
for w1 in list1:
if w1 in list2:
intersect.append(w1)
IOtools.todisc_list(outdir+os.sep+outfilename+".txt", intersect)
fdist = nltk.FreqDist(intersect)
fdist2 = nltk.FreqDist(list2)
for item in list(fdist2):
fdist.inc(item, fdist2[item])
IOtools.todisc_freqdist(outdir+os.sep+"weighted-"+outfilename+".txt", fdist)
return intersect