ea2b8969e20223b33a9bad6df9d5ee8065998855,textgenrnn/utils.py,,textgenrnn_generate,#,39

Before Change


        if word_level:
            text = [meta_token] + prefix.split() if prefix else [meta_token]
        else:
            text = [meta_token] + list(prefix) if prefix else [meta_token]
    next_char = ""

    if not isinstance(temperature, list):
        temperature = [temperature]

    if model_input_count(model) > 1:
        model = Model(inputs=model.input[0], outputs=model.output[1])

    while next_char != meta_token and len(text) < max_gen_length:
        encoded_text = textgenrnn_encode_sequence(text[-maxlen:],
                                                  vocab, maxlen)
        next_temperature = temperature[(len(text) - 1) % len(temperature)]
        next_index = textgenrnn_sample(
            model.predict(encoded_text, batch_size=1)[0],
            next_temperature)
        next_char = indices_char[next_index]
        text += [next_char]

    collapse_char = " " if word_level else ""

    // if single text, ignore sequences generated w/ padding
    // if not single text, strip the <s> meta_tokens
    if single_text:
        text = text[maxlen:]
    else:
        text = text[1:-1]

    text_joined = collapse_char.join(text)

    // If word level, remove spaces around punctuation for cleanliness.
    if word_level:
        //     left_punct = "!%),.:;?@]_}\\n\\t""
        //     right_punct = "$([_\\n\\t""
        punct = "\\n\\t"
        text_joined = re.sub(" ([{}]) ".format(punct), r"\1", text_joined)
        //     text_joined = re.sub(" ([{}])".format(
        //       left_punct), r"\1", text_joined)
        //     text_joined = re.sub("([{}]) ".format(

After Change


        prefix_t = [x.lower() for x in prefix.split()]

    if not word_level and prefix:
        prefix_t = list(prefix)

    if single_text:
        text = prefix_t if prefix else [""]
        max_gen_length += maxlen
    else:
        text = [meta_token] + prefix_t if prefix else [meta_token]

    next_char = ""

    if not isinstance(temperature, list):
        temperature = [temperature]

    if model_input_count(model) > 1:
        model = Model(inputs=model.input[0], outputs=model.output[1])

    while next_char != meta_token and len(text) < max_gen_length:
        encoded_text = textgenrnn_encode_sequence(text[-maxlen:],
                                                  vocab, maxlen)
        next_temperature = temperature[(len(text) - 1) % len(temperature)]
        next_index = textgenrnn_sample(
            model.predict(encoded_text, batch_size=1)[0],
            next_temperature)
        next_char = indices_char[next_index]
        text += [next_char]

    collapse_char = " " if word_level else ""

    // if single text, ignore sequences generated w/ padding
    // if not single text, strip the <s> meta_tokens
    if single_text:
        text = text[maxlen:]
    else:
        text = text[1:-1]

    text_joined = collapse_char.join(text)

    // If word level, remove spaces around punctuation for cleanliness.
    if word_level:
        //     left_punct = "!%),.:;?@]_}\\n\\t""
        //     right_punct = "$([_\\n\\t""
        punct = "\\n\\t"
        text_joined = re.sub(" ([{}]) ".format(punct), r"\1", text_joined)
        //     text_joined = re.sub(" ([{}])".format(
        //       left_punct), r"\1", text_joined)
        //     text_joined = re.sub("([{}]) ".format(
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 2

Instances


Project Name: minimaxir/textgenrnn
Commit Name: ea2b8969e20223b33a9bad6df9d5ee8065998855
Time: 2018-08-05
Author: max@minimaxir.com
File Name: textgenrnn/utils.py
Class Name:
Method Name: textgenrnn_generate


Project Name: uber/ludwig
Commit Name: e3d1e6dfd06c35dec767c53b930fa69fc2ff7b12
Time: 2020-04-14
Author: w4nderlust@gmail.com
File Name: ludwig/utils/visualization_utils.py
Class Name:
Method Name: hyperopt_pair_plot


Project Name: chainer/chainercv
Commit Name: 56a28a3400c4d2735623b5394d5f867fd0bec72a
Time: 2017-05-24
Author: Hakuyume@users.noreply.github.com
File Name: chainercv/utils/testing/apply_detection_link.py
Class Name:
Method Name: apply_detection_link