team4alfanous team mailing list archive
-
team4alfanous team
-
Mailing list archive
-
Message #00291
[Branch ~team4alfanous/alfanous/alfanous-git] Rev 480: provide the suggestions in a dictionary structure instead of a list
------------------------------------------------------------
revno: 480
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Sat 2013-01-05 01:01:14 +0100
message:
provide the suggestions in a dictionary structure instead of a list
and fix the show of them in the WUI (fix #139)
modified:
src/alfanous-desktop/Gui.py
src/alfanous-django/templates/results.html
src/alfanous/Outputs.py
src/alfanous/Suggestions.py
--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git
Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous-desktop/Gui.py'
--- src/alfanous-desktop/Gui.py 2012-12-30 21:47:47 +0000
+++ src/alfanous-desktop/Gui.py 2013-01-05 00:01:14 +0000
@@ -234,9 +234,9 @@
}
output = RAWoutput.do( suggest_flags )
#print output
- suggestions = output["suggest"] if output.has_key( "suggest" ) else []
+ suggestions = output["suggest"] if output.has_key( "suggest" ) else {}
#print suggestions
- if len( suggestions ):
+ if len( suggestions ):
html += _( u"<h1> Suggestions (%(number)s) </h1>" ) % {"number":len( suggestions )}
for key, value in suggestions:
html += _( u"<span class='green'> %(word)s </span> : %(suggestions)s. <br />" ) % {"word": unicode( key ), "suggestions":u"،".join( value )}
=== modified file 'src/alfanous-django/templates/results.html'
--- src/alfanous-django/templates/results.html 2013-01-04 00:11:31 +0000
+++ src/alfanous-django/templates/results.html 2013-01-05 00:01:14 +0000
@@ -20,9 +20,9 @@
{% for suggestion_key, suggestion_item in suggestions.suggest.items %}
<p dir='{{ bidi }}' >
<div class='word_details'>
- <span style=' font-size:14pt; color:#00aa00;'> {{ suggestion_key }} </span>
- <div class='details_label word_info0'> {{ _("word") }} | {{ suggestion_item|first }} </div>
- {% for suggestion_sub_key, suggestion_sub_item in suggestion_item|slice:"1" %}
+ <span style=' font-size:14pt; color:#00aa00;'> {{ forloop.counter }} </span>
+ <div class='details_label word_info0'> {{ _("word") }} | {{ suggestion_key }} </div>
+ {% for suggestion_sub_item in suggestion_item %}
<a class='no_decoration' href="?{% build_search_link params suggestion_sub_item 1 False %}">
<div class='details_label word_stat1 clickable'> {{ suggestion_sub_item }}</div></a>
{% empty %}
=== modified file 'src/alfanous/Outputs.py'
--- src/alfanous/Outputs.py 2013-01-04 20:03:59 +0000
+++ src/alfanous/Outputs.py 2013-01-05 00:01:14 +0000
@@ -357,10 +357,15 @@
def _suggest( self, flags ):
""" return suggestions """
query = flags["query"] if flags.has_key( "query" ) else self._defaults["flags"]["query"]
+ #preprocess query
+ query = query.replace( "\\", "" )
+ if not isinstance( query, unicode ):
+ query = unicode( query , 'utf8' )
try:
- output = self.QSE.suggest_all( unicode( query, 'utf8' ) ).items()
+ output = self.QSE.suggest_all( query )
except Exception:
- output = []
+ output = {}
+
return {"suggest":output}
def _search( self, flags ):
=== modified file 'src/alfanous/Suggestions.py'
--- src/alfanous/Suggestions.py 2012-12-25 04:16:11 +0000
+++ src/alfanous/Suggestions.py 2013-01-05 00:01:14 +0000
@@ -93,6 +93,7 @@
for key, values in unit.items():
if D.has_key( key ):
D[key].extend[list( values )]
- else: D[key] = list( values )
+ else:
+ D[key] = list( values )
return D