当前位置: 首页>>代码示例>>Python>>正文


Python Detector.check_for_duplicates方法代码示例

本文整理汇总了Python中detector.Detector.check_for_duplicates方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.check_for_duplicates方法的具体用法?Python Detector.check_for_duplicates怎么用?Python Detector.check_for_duplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在detector.Detector的用法示例。


在下文中一共展示了Detector.check_for_duplicates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Moore

# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import check_for_duplicates [as 别名]
#! /usr/bin/env python
# Main near-duplicate detection "runner"
#
# Written by Parker Moore (pjm336)
# http://www.parkermoore.de

import operator, copy
from detector import Detector

if __name__ == "__main__":
    # run the program
    detector = Detector('./test')
    print "Checking for duplicates using NDD..."
    duplicates = detector.check_for_duplicates()
    if duplicates:
        print "Duplicates found (Jaccard coefficient > 0.5):"
        print duplicates
    
    print "Printing three nearest neighbors of the first 10 files..."
    filenames_of_first_ten = [detector.filename("file%02d.txt") % (f,) for f in xrange(10)]
    filenames_of_first_one_hundred = [detector.filename("file%02d.txt") % (f,) for f in xrange(100)]
    for index1, j in enumerate(filenames_of_first_ten):
        jaccard_coefficients = [0] * 100
        for index2, d in enumerate(filenames_of_first_one_hundred):
            if index1 != index2:
                jaccard_coefficients[index2] = detector.index.get_jaccard(j, d)
        three_nearest = []
        nearest_count = -1
        jcos = copy.deepcopy(jaccard_coefficients)
        while len(three_nearest) < 3:
            index,coefficient = max(enumerate(jcos), key=operator.itemgetter(1))
开发者ID:hellcoderz,项目名称:near-dup-detection,代码行数:33,代码来源:ndd.py


注:本文中的detector.Detector.check_for_duplicates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。