本文整理汇总了Python中Document.Document.get_tf_for方法的典型用法代码示例。如果您正苦于以下问题:Python Document.get_tf_for方法的具体用法?Python Document.get_tf_for怎么用?Python Document.get_tf_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document.Document
的用法示例。
在下文中一共展示了Document.get_tf_for方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Document import Document [as 别名]
# 或者: from Document.Document import get_tf_for [as 别名]
def main():
clustered_corpus_path = 'clustered_corpus'
clustered_corpus = read_clustered_corpus(clustered_corpus_path)
corpus = merge_clustered_corpus_into_a_single_corpus(clustered_corpus)
target_file_path = 'target.txt'
text = read_text_file(target_file_path)
document = Document(text)
corpus = Corpus(corpus)
clustered_corpus = ClusteredCorpus(clustered_corpus)
candidate_to_rank_mapping = {}
candidate_to_params_mapping = {}
candidate_to_dfs_in_each_cluster_mapping = {}
for candidate in document.get_candidates():
tf = math.log(1.0 + document.get_tf_for(candidate), 10.0)
# tf = document.get_tf_for(candidate)
idf = math.log(1.0 + 1.0 / corpus.get_df_for(candidate), 2.0)
cu = clustered_corpus.get_cu_for(candidate)
rank = cu
# rank = tf * cu
# rank = tf * idf
dfs_in_each_cluster = clustered_corpus.get_dfs_in_each_cluster_for(candidate)
candidate_representative = corpus.get_representative_for(candidate)
candidate_to_rank_mapping[candidate_representative] = rank
candidate_to_params_mapping[candidate_representative] = (tf, idf, cu)
candidate_to_dfs_in_each_cluster_mapping[candidate_representative] = dfs_in_each_cluster
table = generate_table_based_on(
candidate_to_rank_mapping,
candidate_to_params_mapping,
candidate_to_dfs_in_each_cluster_mapping
)
save_as_file(table)
print('Done.')