Matchers using data model utilities based on _get_node() are too slow
See original GitHub issueI was generating candidates from a document where I pretty much needed all the mentions of the bold text in the first column in the tables:
lambda function matcher initialisation:
def get_style_attr(html_attr):
"""This function parse a style string and returns a dict of styles.
eg: 'style=padding-left: 5pt;padding-right: 66pt;font-weight: normal;'
returns => {
'padding-left': '5pt',
'padding-right': '66pt',
'font-weight': 'normal'
}
"""
for attr in html_attr:
if attr.startswith('style'):
beg = attr.find('style=') + 6
return {style.strip().split(':')[0].strip():style.strip().split(':')[1].strip()\
for style in attr[beg:].strip().split(';') if len(style.strip()) > 0}
def name_conditions(span):
if get_parent_tag(span) != 'td':
return False
style_attr = get_style_attr(get_attributes(span))
return style_attr is not None and 'font-weight' in style_attr.keys() and style_attr['font-weight'] == 'bold'
name_lambda_matcher = LambdaFunctionMatcher(func=name_conditions)
candidate extractor:
name_label_extractor = CandidateExtractor(name_label,
[name_ngrams, label_ngrams],
[name_lambda_matcher, label_matcher],
candidate_filter = name_label_filter)
name_label_extractor.apply(docs, parallelism=4)
I am running this on a document with 3620 phrases.
Is this the expected time for this matcher…? or do you see anything here that is causing this…?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
NodePath - Panda3D Manual
Converts the NodePath object into a single stream of data using a BamWriter , and returns that data as a string string. Returns...
Read more >Cytoscape.js
js is an open-source graph theory (a.k.a. network) library written in JS. You can use Cytoscape.js for graph analysis and visualisation.
Read more >Script repository - 3D Slicer documentation - Read the Docs
GetNodeByID() is more appropriate when a module needs to access a MRML node: its behavior is more predictable: it only accepts node ID...
Read more >Webots documentation: Supervisor
This is a utility function that simplifies the task of retrieving the base node without having to define a DEF name for it....
Read more >DRBD 9.0 en - LINBIT
DRBD is a software-based, shared-nothing, replicated storage solution mirroring the content of block devices (hard disks, partitions, logical ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lukehsiao @SenWu I have found that adding an if condition to the lambda function matcher increases the time taken exponentially. Here is the working code with sample documents. test.zip
Closed by #152.
Fix will be included in v0.3.0 (to be released this coming week).