Added support for homophones.
--- a/gadict.gadict Sun Oct 08 19:20:44 2017 +0300
+++ b/gadict.gadict Fri Oct 13 01:44:07 2017 +0300
@@ -18516,13 +18516,14 @@
__
know
- [nəʊ]
- v1
+ [noʊ]
+ v1
+ homo: no
knew
[nuː]
v2
known
- [nəʊn]
+ [noʊn]
v3
v
@@ -22108,7 +22109,8 @@
__
no
- [nəʊ]
+ [noʊ]
+ homo: know
adv
ant: yes
--- a/py/gadict.py Sun Oct 08 19:20:44 2017 +0300
+++ b/py/gadict.py Fri Oct 13 01:44:07 2017 +0300
@@ -34,10 +34,11 @@
class Headword:
- def __init__(self, headword, pron = None, attrs = None):
+ def __init__(self, headword, pron = None, attrs = None, homo = None):
self.headword = headword
self.pron = pron
self.attrs = attrs
+ self.homo = homo
def __str__(self):
return self.headword
@@ -131,6 +132,7 @@
HEADWORD_RE = re.compile( u"^(\\w.*)$" )
HEADWORD_VAR_RE = re.compile(u"^ +(rare|s|pl|v[123]|male|female|comp|super|abbr|Am|Br|Au)$", re.UNICODE)
HEADWORD_PRON_RE = re.compile(u"^ +\\[([a-zˌˈːəæɛɒʊɪɔɜɑʌɚɐɹʃʧθðɡʒŋɾʔ ]+)\\]$", re.UNICODE)
+ HEADWORD_HOMO_RE = re.compile(u"^ +homo: (\\w+)$", re.UNICODE)
TRANSL_POS_RE = re.compile(u"^(?:n|det|pron|adj|v|adv|prep|conj|num|int|phr|phr\\.v|contr|abbr|prefix)$", re.UNICODE)
TRANSL_RE = re.compile(u"^(ru|uk|la|en): ([\\w(].*)$", re.UNICODE)
TRANSL_EX_RE = re.compile(u"""^(ru|uk|la|en)> ([-'"\\w].*)$""", re.UNICODE)
@@ -255,6 +257,7 @@
word = m.group(1)
pron = None
attrs = set()
+ homo = None
while True:
self.readline()
if self.eof or len(self.line) == 0:
@@ -263,10 +266,11 @@
if m is not None:
if word is None:
raise ParseException("""Didn't match previous headword...""")
- self.words.append(Headword(word, pron, attrs))
+ self.words.append(Headword(word, pron, attrs, homo = homo))
word = m.group(1)
pron = None
attrs = set()
+ homo = None
continue
m = self.HEADWORD_PRON_RE.match(self.line)
if m is not None:
@@ -278,8 +282,14 @@
if m is not None:
attrs.add(m.group(1))
continue
+ m = self.HEADWORD_HOMO_RE.match(self.line)
+ if m is not None:
+ if homo is not None:
+ raise ParseException("""Homophones are redefined...""")
+ homo = [s.strip() for s in m.group(1).split(";")]
+ continue
raise ParseException("""Line is not a headword or translation or headword attribute...""")
- self.words.append(Headword(word, pron, attrs))
+ self.words.append(Headword(word, pron, attrs, homo))
def parse_translation_continuation(self):
string = ""
--- a/py/gadict_c5.py Sun Oct 08 19:20:44 2017 +0300
+++ b/py/gadict_c5.py Fri Oct 13 01:44:07 2017 +0300
@@ -124,6 +124,11 @@
l = ["«"+x+"»" for x in hw.attrs]
l.sort()
FOUT.write(", ".join(l))
+ if hw.homo in not None and len(hw.homo) > 0:
+ FOUT.write(" homo: ")
+ l = ["{"+x+"}" for x in hw.homo]
+ l.sort()
+ FOUT.write(", ".join(l))
FOUT.write("\n")
FOUT.write("\n")
for sense in translations:
--- a/py/gadict_srs_anki.py Sun Oct 08 19:20:44 2017 +0300
+++ b/py/gadict_srs_anki.py Fri Oct 13 01:44:07 2017 +0300
@@ -143,6 +143,15 @@
.pron {
color: magenta;
}
+.attrs {
+ color: blue;
+}
+.homo {
+ font-style: italic;
+}
+.homo i {
+ color: green;
+}
.pos {
color: green;
font-style: italic;
@@ -169,9 +178,6 @@
.hypo {
color: #606080;
}
-.attrs {
- color: blue;
-}
span.ex {
font-style: italic;
font-size: .85em;
@@ -511,6 +517,10 @@
singular = (hw.headword, hw.pron)
if 'pl' in hw.attrs:
plural = (hw.headword, hw.pron)
+ if hw.homo is not None and len(hw.homo) > 0:
+ buf.append("<span class='homo'> <i>homo:</i>")
+ buf.append("; ".join(hw.homo))
+ buf.append("</span>")
buf.append("</div>")
direct_from = "".join(buf)
buf = []
--- a/www/CHANGES.rst Sun Oct 08 19:20:44 2017 +0300
+++ b/www/CHANGES.rst Fri Oct 13 01:44:07 2017 +0300
@@ -23,6 +23,11 @@
0.3 800 n/a
======= ======== ========
+v0.13, 2017-xx-xx
+=================
+
+* Added support for homophones.
+
v0.12, 2017-07-29
=================