-
Notifications
You must be signed in to change notification settings - Fork 356
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
Cedict reader #138
Cedict reader #138
Conversation
conceptnet5/readers/cc_cedict.py
Outdated
DATE_RANGE_REGEX = re.compile(r'(.+?)\s\(.+\d.+\),') # date range | ||
PAREN_REGEX = re.compile(r'\(.+?\)') # parenthesis | ||
CHINESE_CHAR_REGEX = re.compile(r'([\u4e00-\u9fff]+[\|·]?)+') # Chinese characters | ||
BRACKETS_REGEX = re.compile(r'\[.+\]') # pronunciation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this regex is too greedy and should have a ?
on it like PAREN_REGEX
does.
I believe that in this definition:
一甲 一甲 [yi1 jia3] /1st rank or top three candidates who passed the imperial examination (i.e. 狀元|状元[zhuang4 yuan2], 榜眼[bang3 yan3], and 探花[tan4 hua1], respectively)/
it will match this text:
[zhuang4 yuan2], 榜眼[bang3 yan3], and 探花[tan4 hua1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular definition would actually have everything inside the parentheses removed before matching the brackets, but the problem was true for a couple of other definitions, so I changed it.
conceptnet5/readers/cc_cedict.py
Outdated
LINE_REGEX = re.compile(r'(.+)\s(.+)\[.+\]\s/(.+)/') # separate traditional and simplified words | ||
DATE_RANGE_REGEX = re.compile(r'(.+?)\s\(.+\d.+\),') # date range | ||
PAREN_REGEX = re.compile(r'\(.+?\)') # parenthesis | ||
CHINESE_CHAR_REGEX = re.compile(r'([\u4e00-\u9fff]+[\|·]?)+') # Chinese characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to exclude the range from U+3400..U+4DBF, which appears in definitions such as:
㐌 㐌 [ta1] /variant of 它[ta1]/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, it also excludes the other CJK extensions with codepoints U+20000 and up, but CEDICT never uses those anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was correct for a couple of definitions, so I ended up switching to regex.compile('([\p{IsIdeo}]+[\|·]?)+')
, per your suggestion.
No description provided.