Skip to content

Commit

Permalink
Merge pull request #290 from sobisonator/patch-1
Browse files Browse the repository at this point in the history
Added UTF-8 support for special characters
  • Loading branch information
minimaxir committed May 22, 2022
2 parents f09f5c8 + 8c0f624 commit 67b6d23
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gpt_2_simple/gpt_2.py
Expand Up @@ -15,6 +15,7 @@
import csv
import argparse
from sys import exit
import codecs

# if in Google Colaboratory
try:
Expand Down Expand Up @@ -303,9 +304,9 @@ def generate_samples():
index += 1
print(text)
maketree(os.path.join(SAMPLE_DIR, run_name))
with open(
with codecs.open(
os.path.join(SAMPLE_DIR, run_name,
'samples-{}').format(counter), 'w') as fp:
'samples-{}').format(counter), 'w', 'utf8') as fp:
fp.write('\n'.join(all_text))

def sample_batch():
Expand Down Expand Up @@ -469,7 +470,7 @@ def generate(sess,
)[:, 1:]

if destination_path:
f = open(destination_path, 'w')
f = codecs.open(destination_path, 'w', 'utf-8')
generated = 0
gen_texts = []
while generated < nsamples:
Expand Down

0 comments on commit 67b6d23

Please sign in to comment.