-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate entries in cedict in two group. First group with single entries Second group with multiple entries or present in first group.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
def separate_entries(): | ||
single_entry = open("text/single_entry.txt", "w", encoding="utf-8") | ||
multiple_entry = open("text/multiple_entry.txt", "w", encoding="utf-8") | ||
|
||
with open('cedict_ts.u8', "r", encoding="utf-8") as f: | ||
lines = f.readlines() | ||
dict_data = [] | ||
not_dict_data = [] | ||
|
||
for line in lines: | ||
data = line.split(" ") | ||
meaning = line.split("/") | ||
|
||
if data[1] not in dict_data: | ||
print("Single: ", line) | ||
dict_data.append(data[1].strip()) | ||
single_entry.write(line) | ||
else: | ||
not_dict_data.append(data[1].strip()) | ||
print("Multiple: ", line) | ||
multiple_entry.write(line) | ||
|
||
single_entry.close() | ||
multiple_entry.close() | ||
|
||
|