本文整理汇总了Python中Detector.Detector.detect方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.detect方法的具体用法?Python Detector.detect怎么用?Python Detector.detect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Detector.Detector
的用法示例。
在下文中一共展示了Detector.detect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: performAnalyse
# 需要导入模块: from Detector import Detector [as 别名]
# 或者: from Detector.Detector import detect [as 别名]
def performAnalyse(self, htmlnode):
se = StructureExtractor()
se.drawFeature(htmlnode)
extractor = Extractor(htmlnode)
extractor.process()
detector = Detector()
detector.detect(htmlnode)
(tp, fp, fn) = self.calcAccTitleLine(htmlnode)
cerr = self.calcAccColumn(htmlnode)
return (tp, fp, fn, cerr)
示例2: process
# 需要导入模块: from Detector import Detector [as 别名]
# 或者: from Detector.Detector import detect [as 别名]
def process(self,root):
se = StructureExtractor()
se.drawFeature(root)
self.extractor = Extractor(root)
self.extractor.process()
#self.crossP = self.extractor.string2sparse(self.htmlnode.attrib['crossP'],self.extractor.totalheight+1)
Config.init()
detector = Detector()#Config.nbTLstr)
detector.detect(root)
self.toolbox.setDetector(detector)
示例3: __init__
# 需要导入模块: from Detector import Detector [as 别名]
# 或者: from Detector.Detector import detect [as 别名]
class Analyser:
def __init__(self):
Config.init()
self.detector = Detector()#Config.nbTLstr)
def analyse(self, xmlfilelist):
parser = etree.XMLParser(recover=True)
total_tp = 0
total_fp = 0
total_fn = 0
fnfid = {}
fpfid = {}
cerrs = dict.fromkeys(['AUTHOR', 'COUNT_READ', 'COUNT_REPLY', 'TITLE', 'TM_POST', 'TM_REPLY'],0)
cerrfiles = {}
num = 0
for xmlfile in xmlfilelist:
#print(xmlfile)
if num % 200 == 0 :
print(num/len(xmlfilelist))
print('REV.150')
print('total_tp:', total_tp)
print('total_fp:', total_fp)
print('total_fn:', total_fn)
print('fnfid:', fnfid)
print('fpfid:', fpfid)
print('cerrs:',cerrs)
print('cerrfiles:', cerrfiles)
num += 1
root = etree.parse(xmlfile,parser).getroot()
htmlnode = root[0]
se = StructureExtractor()
se.drawFeature(htmlnode)
extractor = Extractor(htmlnode)
extractor.process()
self.detector.detect(htmlnode)
(tp, fp, fn) = self.calcAccTitleLine(htmlnode)
total_tp += tp
total_fp += fp
total_fn += fn
if fn == 0:
cerr = self.calcAccColumn(htmlnode)
for k in cerr:
cerrs[k] += 1
if len(cerr)>0:
cerrfiles[path.basename(xmlfile)] = (cerr, root.attrib['fid'])
if fp > 0:
#print(xmlfile)
fpfid[root.attrib['fid']] = fpfid.get(root.attrib['fid'],0) + 1
if fn > 0:
print(xmlfile)
fnfid[root.attrib['fid']] = fnfid.get(root.attrib['fid'],0) + 1
print('REV.150')
print('total_tp:', total_tp)
print('total_fp:', total_fp)
print('total_fn:', total_fn)
print('fnfid:', fnfid)
print('fpfid:', fpfid)
print('cerrs:',cerrs)
print('cerrfiles:', cerrfiles)
def analyseOnce(self, xmlfile):
parser = etree.XMLParser(recover=True)
root = etree.parse(xmlfile,parser).getroot()
htmlnode = root[0]
return self.performAnalyse(htmlnode)
def performAnalyse(self, htmlnode):
se = StructureExtractor()
se.drawFeature(htmlnode)
extractor = Extractor(htmlnode)
extractor.process()
detector = Detector()
detector.detect(htmlnode)
(tp, fp, fn) = self.calcAccTitleLine(htmlnode)
cerr = self.calcAccColumn(htmlnode)
return (tp, fp, fn, cerr)
def calcAccTitleLine(self, root):
ptls = set(root.findall('.//*[@predict="{}"]'.format(LABEL['TITLE_LINE'])))
ttls = set(root.findall('.//*[@label="{}"]'.format(LABEL['TITLE_LINE'])))
tp = len(ptls & ttls)
fp = len(ptls) - tp
fn = len(ttls) - tp
return (tp, fp, fn)
def calcAccColumn(self, root):
k = 1
columns = {}
while True:
cs = root.findall('.//*[@column="{}"]'.format(k))
if len(cs) == 0:
break
columns[k] = set(cs)
k += 1
dls = ['AUTHOR', 'COUNT_READ', 'COUNT_REPLY', 'TITLE', 'TM_POST', 'TM_REPLY']
err = set()
for key in dls:
ts = set(root.findall('.//*[@predict="{}"]//*[@label="{}"]'.format(LABEL['TITLE_LINE'],LABEL[key])))
cs = set()
#.........这里部分代码省略.........