e3931c33e2e5f4b148a918d798cc27224ed090b7,examples/bert/utils/tokenization.py,,convert_to_unicode,#Any#,29

Before Change


    
    Converts `text` to Unicode (if it"s not already), assuming utf-8 input.
    
    if six.PY3:
        if isinstance(text, str):
            return text
        elif isinstance(text, bytes):
            return text.decode("utf-8", "ignore")
        else:
            raise ValueError("Unsupported string type: %s" % (type(text)))
    elif six.PY2:
        if isinstance(text, str):
            return text.decode("utf-8", "ignore")
        elif isinstance(text, unicode):
            return text
        else:
            raise ValueError("Unsupported string type: %s" % (type(text)))
    else:
        raise ValueError("Not running on Python2 or Python 3?")


def printable_text(text):
    Returns text encoded in a way suitable for print or `tf.logging`.

    // These functions want `str` for both Python2 and Python3, but in one case

After Change



def convert_to_unicode(text):
    Returns the given argument as a unicode string.
    return tf.compat.as_text(text)

def printable_text(text):
    Returns text encoded in a way suitable for print or `tf.logging`.
    return tf.compat.as_str_any(text)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: asyml/texar
Commit Name: e3931c33e2e5f4b148a918d798cc27224ed090b7
Time: 2018-11-29
Author: haoranshi97@gmail.com
File Name: examples/bert/utils/tokenization.py
Class Name:
Method Name: convert_to_unicode


Project Name: ray-project/ray
Commit Name: 1775e89f262111791fabfd40f80a24f74738fe54
Time: 2020-04-28
Author: sven@anyscale.io
File Name: rllib/policy/policy.py
Class Name:
Method Name: clip_action


Project Name: asyml/texar
Commit Name: e3931c33e2e5f4b148a918d798cc27224ed090b7
Time: 2018-11-29
Author: haoranshi97@gmail.com
File Name: examples/bert/utils/tokenization.py
Class Name:
Method Name: printable_text