question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Matchers using data model utilities based on _get_node() are too slow

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
prabhkarancommented, Sep 12, 2018

@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

0reactions
lukehsiaocommented, Sep 14, 2018

Closed by #152.

Fix will be included in v0.3.0 (to be released this coming week).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found