1d6771befb95f4ae94f308899633294a003dcfd6,src/fonduer/utils/data_model_utils/structural.py,,common_ancestor,#,172

Before Change


    ancestors = [np.array(span.sentence.xpath.split("/")) for span in spans]
    min_len = min([a.size for a in ancestors])
    arrays = np.array([a[:min_len] for a in ancestors])
    arg_min = np.argmin(arrays[:-1] == arrays[1:], axis=1)
    val = np.min(arg_min[np.nonzero(arg_min)])
    return list(ancestors[0][:val])

After Change


    min_len = min([a.size for a in ancestors])
    ancestor = ancestors[0]
    ind = 0  // all the ancestors are common up to this index (exclusive).
    while ind < min_len:
        if not all([a[ind] == ancestor[ind] for a in ancestors]):
            break
        ind += 1
    return list(ancestors[0][:ind])


def lowest_common_ancestor_depth(c: Tuple[SpanMention, ...]) -> int:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: HazyResearch/fonduer
Commit Name: 1d6771befb95f4ae94f308899633294a003dcfd6
Time: 2020-07-24
Author: hiromu.hota@hal.hitachi.com
File Name: src/fonduer/utils/data_model_utils/structural.py
Class Name:
Method Name: common_ancestor


Project Name: HazyResearch/fonduer
Commit Name: 1d6771befb95f4ae94f308899633294a003dcfd6
Time: 2020-07-24
Author: hiromu.hota@hal.hitachi.com
File Name: src/fonduer/utils/data_model_utils/structural.py
Class Name:
Method Name: lowest_common_ancestor_depth


Project Name: UFAL-DSG/tgen
Commit Name: a3c24e5e3222592a0c4e002ac47e3b7e048327d1
Time: 2014-03-26
Author: odusek@ufal.mff.cuni.cz
File Name: tgen/tgen_random.py
Class Name: RandomTTreeGenerator
Method Name: generate_tree