From bcf6e967422fcad3f61501b40b6645710fc40bd3 Mon Sep 17 00:00:00 2001 From: Shashwat Pandey Date: Fri, 21 Aug 2020 14:23:46 +0530 Subject: [PATCH] Fix encoding issue (#11) Now supports all languages Tested with korean input --- classes.txt | 2 +- reader.py | 2 +- xml/image-0000016.xml | 2 +- xml/subdir/image-0000003.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classes.txt b/classes.txt index 4545a76..cc290e2 100644 --- a/classes.txt +++ b/classes.txt @@ -3,4 +3,4 @@ minivan auto truck minibus -sedan +가각 diff --git a/reader.py b/reader.py index bc54647..96f848a 100644 --- a/reader.py +++ b/reader.py @@ -17,6 +17,6 @@ def get_xml_files(self): @staticmethod def get_classes(filename="classes.txt"): - with open(os.path.join(os.path.dirname(os.path.realpath('__file__')), filename), "r") as f: + with open(os.path.join(os.path.dirname(os.path.realpath('__file__')), filename), "r", encoding="utf8") as f: lines = f.readlines() return {value: key for (key, value) in enumerate(list(map(lambda x: x.strip(), lines)))} diff --git a/xml/image-0000016.xml b/xml/image-0000016.xml index 778ef66..8241ba3 100644 --- a/xml/image-0000016.xml +++ b/xml/image-0000016.xml @@ -7,7 +7,7 @@ 0 - sedan + 가각 Unspecified 0 0 diff --git a/xml/subdir/image-0000003.xml b/xml/subdir/image-0000003.xml index 4a54219..55d735a 100644 --- a/xml/subdir/image-0000003.xml +++ b/xml/subdir/image-0000003.xml @@ -19,7 +19,7 @@ - sedan + 가각 Unspecified 0 0