91287eb35a52102b12d523e9f7194808b5cf1a45,onmt/utils/alignment.py,,build_align_pharaoh,#Any#,66

Before Change



    for tgt_id, src_id in enumerate(tgt_align_src_id.tolist()):
        align_pairs.append(str(src_id) + "-" + str(tgt_id))
    align_pairs.sort(key=lambda x: int(x.split("-")[-1]))  // sort by tgt_id
    align_pairs.sort(key=lambda x: int(x.split("-")[0]))  // sort by src_id
    return align_pairs

After Change


    or empty list if it"s None.
    
    align_pairs = []
    if isinstance(valid_alignment, torch.Tensor):
        tgt_align_src_id = valid_alignment.argmax(dim=-1)

        for tgt_id, src_id in enumerate(tgt_align_src_id.tolist()):
            align_pairs.append(str(src_id) + "-" + str(tgt_id))
        align_pairs.sort(key=lambda x: int(x.split("-")[-1]))  // sort by tgt_id
        align_pairs.sort(key=lambda x: int(x.split("-")[0]))  // sort by src_id
    return align_pairs


def to_word_align(src, tgt, subword_align, mode):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: 91287eb35a52102b12d523e9f7194808b5cf1a45
Time: 2020-03-18
Author: linxiao.zeng@gmail.com
File Name: onmt/utils/alignment.py
Class Name:
Method Name: build_align_pharaoh


Project Name: NervanaSystems/nlp-architect
Commit Name: 57e30a889f430cf948e26ee54e497004c501ee43
Time: 2018-06-10
Author: shira.guskin@intel.com
File Name: set_expansion_demo/ui/main.py
Class Name:
Method Name: search_callback


Project Name: keras-team/keras
Commit Name: 69d5139b8ccc860cd3ed8b63be83a104ceeedafb
Time: 2016-08-09
Author: francois.chollet@gmail.com
File Name: keras/engine/topology.py
Class Name: Container
Method Name: __init__


Project Name: NifTK/NiftyNet
Commit Name: 84caf3151dbf0731f4c7a6fe079cfad5b26687d6
Time: 2018-05-23
Author: guotai.wang.14@ucl.ac.uk
File Name: niftynet/layer/discrete_label_normalisation.py
Class Name:
Method Name: find_set_of_labels