Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize file reading by using for-loop iteration over readline() #45

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions Kasa/Preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,14 @@ def read_parallel_dataset(self,filepath_twi='../data/jw300.en-tw.tw',
# read english data
english_data = []
with open(filepath_english, encoding='utf-8') as file:
line = file.readline()
cnt = 1
while line:
for line in file:
english_data.append(line.strip())
line = file.readline()
cnt += 1

# read twi data
twi_data = []
with open(filepath_twi, encoding='utf-8') as file:

# twi=file.read()
line = file.readline()
cnt = 1
while line:
for line in file:
twi_data.append(line.strip())
line = file.readline()
cnt += 1

return twi_data,english_data

Expand Down
Loading