[Hejes-devel] [1421] spell.py: new exception dictionary HOMONYMS, e.g.

hejes-devel at nytud.hu hejes-devel at nytud.hu
Thu Jul 16 15:20:07 CEST 2015


Revision: 1421
Author:   mihaltz
Date:     2015-07-16 15:20:06 +0200 (Thu, 16 Jul 2015)
Log Message:
-----------
spell.py: new exception dictionary HOMONYMS, e.g. ke1rd

Modified Paths:
--------------
    trunk/web2py/applications/helyesiras_webdev/modules/spell.py

Modified: trunk/web2py/applications/helyesiras_webdev/modules/spell.py
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/modules/spell.py	2015-07-16 12:11:33 UTC (rev 1420)
+++ trunk/web2py/applications/helyesiras_webdev/modules/spell.py	2015-07-16 13:20:06 UTC (rev 1421)
@@ -43,7 +43,18 @@
 VOWELS = [u'a', 'á', u'e', u'é', u'i', u'í', u'o', u'ó', u'ö', u'ő', u'u', u'ú', u'ü', u'ű']
 """Used by get_productive_tips()"""
 
+"""Another exception dictionary, used before the engines: "word (utf8)" => "explaining text (utf8)"
+Explaining text may include markmin formatting codes (see http://www.web2py.com/init/static/markmin.html)
+The special code `` ``:BR means line break.
+"""
+HOMONYMS = {
+  "kérd": """1. ’''Kérd'' el a könyvet!’ (A ''kér'' ige egyes szám, második személyű, felszólító módú alakja.)
 
+2. ’Ő ''kérd'' valamit.’ (A kérd [’kérdez’] ige egyes szám, harmadik személyű, kijelentő módú, alanyi ragozású alakja.)`` ``:BR
+Ebben a formában ritkán használatos, inkább első és második személyben, pl. ’Miért ''kérded''?’`` ``:BR
+Felszólító módban, egyes szám, harmadik személyben két d-vel: „Ne ''kérdd'' az én siralmimnak okát” (Balassi) """
+}
+
 """Exception dictionary, used before the engines
 File format: wordform TAB 1 (wf. is correct) or 0 (wf. is incorrect) TAB suggestion if incorrect (or empty if correct)
 """
@@ -373,8 +384,11 @@
   for i, tok in enumerate(utoks):
     # call humor for stemming and morph. analysis
     tok8 = tok.encode('utf8').replace(',', '')
+    # check in HOMONYMS dict first
+    if tok8 in HOMONYMS:
+      ret.append( (True, [], {u'markmin': safe_unic(HOMONYMS[tok8])}) ) # 'markmin' key in tips: format in view with markmin
+      continue # no need for others
     hanas = StemmingAnalysis(tok8).getAnas()
-    #print(u'ptips="{0}"'.format(ptips))
     # get dictionary-based tips
     tips = get_dictionary_tips(tok8, hanas, db)
     # get productive tips




More information about the Hejes-devel mailing list