d7bcbade517750cc4fdb7642415e4cf05ae584e8,tutorial/utils.py,,collect_pubtator_annotations,#,8

Before Change


    Given a list of ddlite Documents with PubTator/CDR annotations,
    extract a dictionary of annotations by type.
    
    annotations = defaultdict(list)
    for a in doc.attribs["root"].xpath(".//annotation"):

        // Relation annotations
        if len(a.xpath("./infon[@key="relation"]")) > 0:
            type = a.xpath("./infon[@key="relation"]/text()")[0]
            types = a.xpath("./infon[@key != "relation"]/@key")
            mesh_ids = a.xpath("./infon[@key != "relation"]/text()")
            annotations[type].append(PubtatorRelation(types=types, mesh_ids=mesh_ids))

        // Mention annotations
        else:
            txt = a.xpath("./text/text()")[0]

After Change


            
            // Get sentence id and relative character offset
            si = len(sent_offsets) - 1
            for i,so in enumerate(sent_offsets):
                if offset == so:
                    si = i
                    break
                elif offset < so:
                    si = i - 1
                    break
            //offset -= sent_offsets[si]
            ngrams.append(Ngram(offset, offset + length - 1, sents[si], metadata={
                "mesh_id" : mesh, "type" : type}))
    return ngrams
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: snorkel-team/snorkel
Commit Name: d7bcbade517750cc4fdb7642415e4cf05ae584e8
Time: 2016-07-03
Author: ajratner@gmail.com
File Name: tutorial/utils.py
Class Name:
Method Name: collect_pubtator_annotations


Project Name: markovmodel/PyEMMA
Commit Name: b69a4513d333266b032e11f9563d6bd14830aa86
Time: 2018-06-21
Author: m.scherer@fu-berlin.de
File Name: conftest.py
Class Name:
Method Name: pytest_collection_modifyitems


Project Name: jbms/beancount-import
Commit Name: bc19ed6b434f77e5758f4baf9cb23ed5d2b25a72
Time: 2020-08-07
Author: dumbpyx@gmail.com
File Name: beancount_import/source/generic_importer_source.py
Class Name: ImporterSource
Method Name: prepare