[Hejes-devel] [1469] Integrated new spell.py into suggest controller and view
hejes-devel at nytud.hu
hejes-devel at nytud.hu
Thu Sep 3 03:15:18 CEST 2015
Revision: 1469
Author: mihaltz
Date: 2015-09-03 03:15:18 +0200 (Thu, 03 Sep 2015)
Log Message:
-----------
Integrated new spell.py into suggest controller and view
Modified Paths:
--------------
trunk/web2py/applications/helyesiras_webdev/controllers/default.py
trunk/web2py/applications/helyesiras_webdev/progress.log
trunk/web2py/applications/helyesiras_webdev/views/default/suggest.html
Modified: trunk/web2py/applications/helyesiras_webdev/controllers/default.py
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/controllers/default.py 2015-09-02 23:27:20 UTC (rev 1468)
+++ trunk/web2py/applications/helyesiras_webdev/controllers/default.py 2015-09-03 01:15:18 UTC (rev 1469)
@@ -164,10 +164,8 @@
Author: MM
Returns a dictionary with the following keys + values:
form: a HTML form for entering the word to hyphenate
- res_humor, res_hunspell: if form is not submitted, empty arrays, otherwise lists [(token_is_correct, [list_of_suggestions]), ...] returned by humor and hunspell
- res_union: like the other 2, but the union of the 2 engines' outputs
- res_with_tips: [(token_is_correct, suggestions, tips), ...] = like res_union + a dictionary containing usage tips for each token
- (see documentation for spell.call_humor_spellchecker_cmdline_ntok()).
+ res_akh11, res_akh12: if form is not submitted, empty arrays, otherwise lists [(token_is_correct, [list_of_suggestions]), ...] returned by hunspell tuned to akh11 and akh12
+ res_tips: a list of dictionaries containing usage tips for each token
toks: if form is not submitted, an empty array, otherwise contains the tokens of the string inputted in the form + added lower-case versions
origtoks: like toks, but without the automatically added lowercase forms
status: 1: normal, -1: user error, 0: no input
@@ -184,7 +182,7 @@
try:
inp = form.vars.word if form.vars.word else request.get_vars['q'] # the input from either the form or the GET request
if not spell.input_check(unicode(inp, 'utf8')):
- return dict(status=-1, form=form, res_with_tips=[], res_union=[], res_humor=[], res_hunspell=[], toks=[])
+ return dict(status=-1, form=form, res_akh11=[], res_akh12=[], res_tips=[], toks=[], origtoks=[])
otoks = toks = inp.split(' ')
# add lower-cased versions of upper/titlecase tokens (+ convert to unicode):
tmp = []
@@ -194,20 +192,21 @@
ut = unicode(t, 'utf8')
tmp.append(t)
utoks.append(ut)
- if len(ut)>0 and ut[0].isupper():
- tmp.append(t.lower())
- utoks.append(ut.lower())
+ # Add Titlecase words as lowercase disabled!
+ #if len(ut)>0 and ut[0].isupper():
+ # tmp.append(t.lower())
+ # utoks.append(ut.lower())
toks = tmp
# call engines
- res1 = [] # spell.call_humor_spellchecker_cmdline_ntok(toks)
- res2 = [] # spell.call_hunspell_cmdline_ntok(toks)
- res_u = [] #res_u = spell.union_humor_hunspell([unicode(x, 'utf8') for x in toks])
- res_wtips = spell.process(utoks, dbdict)
- return dict(status=1, form=form, res_with_tips=res_wtips, res_union=res_u, res_humor=res1, res_hunspell=res2, toks=toks, origtoks=otoks)
+ res = spell.process(utoks, dbdict)
+ res_akh11 = [(r['akh11_correct'], r['akh11_suggestions']) for r in res]
+ res_akh12 = [(r['akh12_correct'], r['akh12_suggestions']) for r in res]
+ res_tips = [r['tips'] for r in res]
+ return dict(status=1, form=form, res_akh11=res_akh11, res_akh12=res_akh12, res_tips=res_tips, toks=toks, origtoks=otoks)
except:
global EXCEPTIONMSG
response.flash = EXCEPTIONMSG
- return dict(status=0, form=form, res_with_tips=[], res_union=[], res_humor=[], res_hunspell=[], toks=[], origtoks=[])
+ return dict(status=0, form=form, res_akh11=[], res_akh12=[], res_tips=[], toks=[], origtoks=[])
def hyph():
Modified: trunk/web2py/applications/helyesiras_webdev/progress.log
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/progress.log 2015-09-02 23:27:20 UTC (rev 1468)
+++ trunk/web2py/applications/helyesiras_webdev/progress.log 2015-09-03 01:15:18 UTC (rev 1469)
@@ -1463,3 +1463,49 @@
[2015-09-02 18:56:34] EDIT helyesiras_webdev/views/default/predict.html: -2
[2015-09-02 18:57:00] EDIT helyesiras_webdev/views/default/predict.html: 0
[2015-09-02 18:57:23] EDIT helyesiras_webdev/views/default/predict.html: 0
+[2015-09-03 01:10:26] EDIT helyesiras_webdev/controllers/default.py: -2
+[2015-09-03 01:16:06] EDIT helyesiras_webdev/controllers/default.py: 3
+[2015-09-03 01:17:50] EDIT helyesiras_webdev/controllers/default.py: 1
+[2015-09-03 01:18:52] EDIT helyesiras_webdev/controllers/default.py: -4
+[2015-09-03 01:19:19] EDIT helyesiras_webdev/controllers/default.py: 0
+[2015-09-03 01:28:43] EDIT helyesiras_webdev/views/default/suggest.html: -5
+[2015-09-03 01:29:42] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:32:12] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:33:31] EDIT helyesiras_webdev/views/default/suggest.html: -3
+[2015-09-03 01:37:22] EDIT helyesiras_webdev/views/default/suggest.html: 1
+[2015-09-03 01:41:28] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:43:13] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:45:33] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:47:42] EDIT helyesiras_webdev/controllers/default.py: 1
+[2015-09-03 01:49:14] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:49:25] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:50:36] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:50:41] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 01:59:56] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:04:18] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:09:16] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:14:13] EDIT helyesiras_webdev/views/default/suggest.html: 1
+[2015-09-03 02:15:55] EDIT helyesiras_webdev/views/default/suggest.html: 3
+[2015-09-03 02:17:13] EDIT helyesiras_webdev/views/default/suggest.html: 2
+[2015-09-03 02:19:49] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:20:51] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:22:03] EDIT helyesiras_webdev/views/default/suggest.html: 1
+[2015-09-03 02:22:55] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:23:33] EDIT helyesiras_webdev/views/default/suggest.html: -1
+[2015-09-03 02:24:36] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:25:00] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:27:07] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:29:45] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:30:18] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:33:34] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:38:49] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 02:40:14] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:00:32] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:01:32] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:01:58] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:03:32] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:04:07] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:06:36] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:09:28] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:11:10] EDIT helyesiras_webdev/views/default/suggest.html: 0
+[2015-09-03 03:11:28] EDIT helyesiras_webdev/views/default/suggest.html: 0
Modified: trunk/web2py/applications/helyesiras_webdev/views/default/suggest.html
===================================================================
--- trunk/web2py/applications/helyesiras_webdev/views/default/suggest.html 2015-09-02 23:27:20 UTC (rev 1468)
+++ trunk/web2py/applications/helyesiras_webdev/views/default/suggest.html 2015-09-03 01:15:18 UTC (rev 1469)
@@ -61,9 +61,7 @@
<!-- Dumping variables for debugging:
toks: {{=toks}}<br/>
-res_humor: {{=res_humor}}<br/>
-res_hunspell: {{=res_hunspell}}<br/>
-res_union: {{=res_union}}<br/><br/>
+res_tips: {{=res_tips}}</br>
-->
{{if status == -1:}}
@@ -72,16 +70,10 @@
</div>
{{pass}}
-{{if res_with_tips != []:}}
+{{if res_akh12 != []:}}
-{{if res_with_tips[0] == None:}}
-<div class="error2">Elnézést kérünk, a feldolgozás során váratlan hiba történt. Kérjük, próbálja újra később.</div>
-{{pass}}
-
-{{if res_with_tips[0] != None:}}
-
{{# Redirections to other modules: kulon-egybe or predict}}
-{{if (len(origtoks) > 1 or (len(origtoks) == 1 and '-' in origtoks[0])) and unicode(origtoks[0], 'utf8')[0].islower() and len([x[0] for x in res_with_tips if not x[0]]) == 0:}}
+{{if (len(origtoks) > 1 or (len(origtoks) == 1 and '-' in origtoks[0])) and unicode(origtoks[0], 'utf8')[0].islower() and len([x[0] for x in res_akh12 if not x[0]]) == 0:}}
<div class="result-kulegy2">
Ön több szót is megadott. Ha arra kíváncsi, hogy {{=def_art_uni(origtoks[0])}} "{{=' '.join(origtoks)}}" szavakat együtt, egy kifejezésben vagy szóösszetételben hogyan lehet helyesen leírni (külön, egybe vagy kötőjellel), {{=A('próbálja ki', _href=URL(c='default', f='kulegy', vars={'q': ' '.join(origtoks)}))}} <span class="toolname">Külön vagy egybe?</span> eszközünkkel!
</div>
@@ -93,18 +85,24 @@
{{pass}}
<ul class="result">
-{{for t, s in zip(toks, res_with_tips):}}
-<li unknown={{='YES' if not s[0] else 'NO'}}>„{{=t}}”:
+{{for t, s, s11, p in zip(toks, res_akh12, res_akh11, res_tips):}}
+ <li unknown={{='NO' if s[0] else ('YESNO' if s11[0] else 'YES')}}>„{{=t}}”:
{{if s[0]:}}
<b>helyes</b>
-{{else:}}
+{{pass}}
+{{if not s[0] and s11[0]:}}
+ <br/>
+ <a href="{{=URL(f='akh11')}}" target="_blank">AkH11</a> szerint: helyes<br/>
+ <a href="{{=URL(f='akh12')}}" target="_blank">AkH12</a> szerint: ismeretlen{{if s[1] != []:}}; javaslatok: <span class="suggest_list">{{=', '.join(s[1])}}</span>{{pass}}
+{{pass}}
+{{if not s[0] and not s11[0]:}}
<b>ismeretlen</b>
{{if s[1] != []:}}
<br/>Javaslatok: <span class="suggest_list">{{=', '.join(s[1])}}</span>
{{pass}}
{{pass}}
-{{if s[2] != dict(): }}
- {{tips = s[2]}}
+{{if len(p) != 0: }}
+ {{tips = p}}
<div class="suggest_tips">
{{if 'markmin' in tips:}}
{{=MARKMIN(tips['markmin'].encode('utf8'), extra=dict(BR=lambda x:BR()))}}
@@ -134,14 +132,17 @@
</li>
{{pass}}
</ul>
+
{{pass}}
-{{pass}}
+
+
<div class="mobile-clearfix"></div>
<div id="shareblock2">
<a href="http://www.facebook.com/sharer.php?u={{=URL(host=True, f=request.function)}}" id="share_f2" target="_blank">megosztás facebookon</a>
<a href="#" id="share_button2">Megosztás</a>
<div id="sharebox2"><span id="share_close2"> </span><input name="shareurl" type="text" value="{{=get_share_url()}}"></div>
</div>
+
{{block moreinfo_akh}}
<div class="block-mobile-hide"><p>
{{=A('3. fejezet: A hangjelölés (17–93. pont)', _href=URL(c='default', f='akh12', anchor='F3'))}}
More information about the Hejes-devel
mailing list