← Back to team overview

team4alfanous team mailing list archive

[Branch ~team4alfanous/alfanous/alfanous-git] Rev 408: change the converting way of Query from QString to unicode, this will fix #63

 

------------------------------------------------------------
revno: 408
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Tue 2012-10-30 18:53:26 +0100
message:
  change the converting way of Query from QString to unicode, this will fix #63
  
  the problem was when converting the query, it will be a set of introgation marks "????????";
  this is considered as a wildcarded query and it takes long time to be retrieved
modified:
  src/alfanous-desktop/Gui.py
  src/alfanous/Outputs.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-10-05 00:59:07 +0000
+++ src/alfanous-desktop/Gui.py	2012-10-30 17:53:26 +0000
@@ -122,7 +122,7 @@
         self.o_reverse.setChecked( boolean( config["sorting"]["reverse"] )if config.has_key( "sorting" ) else False )
 
         self.o_prev.setChecked( boolean( config["extend"]["prev"] ) if config.has_key( "extend" ) else False )
-        self.o_suiv.setChecked( boolean( config["extend"]["suiv"] )if config.has_key( "extend" ) else False )
+        self.o_suiv.setChecked( boolean( config["extend"]["suiv"] ) if config.has_key( "extend" ) else False )
 
         self.o_word_stat.setChecked( boolean( config["extend"]["word_stat"] )if config.has_key( "extend" ) else False )
         self.o_aya_info.setChecked( boolean( config["extend"]["aya_info"] )if config.has_key( "extend" ) else False )
@@ -223,7 +223,7 @@
         self.o_query.clear()
         self.o_query.addItems( self.history )
         self.o_query.setCurrentIndex( 0 )
-
+	
         ###
 
         limit = self.o_limit.value()
@@ -235,8 +235,8 @@
                 "query": self.o_query.currentText()
                 }
         output = RAWoutput.do( suggest_flags )
-        #print output
-        suggestions = output["suggest"] if output.has_key( "suggest" ) else []
+        #print output     
+	suggestions = output["suggest"] if output.has_key( "suggest" ) else []
         #print suggestions
         if len( suggestions ):
 	    html += _( u"<h1> Suggestions (%(number)s) </h1>" ) % {"number":len( suggestions )}
@@ -246,7 +246,7 @@
         #search
         results, terms = None, []
         search_flags = {"action":"search",
-                 "query": self.o_query.currentText(),
+                 "query": unicode(self.o_query.currentText()),
                  "sortedby":"score" if self.o_sortedbyscore.isChecked() \
                         else "mushaf" if self.o_sortedbymushaf.isChecked() \
                         else "tanzil" if self.o_sortedbytanzil.isChecked() \
@@ -279,7 +279,8 @@
         #print words_info
         if self.o_word_stat.isChecked():
             html += u'<h1> Words ( %(nb_words)d words reported %(nb_matches)d times ): </h1>' % results["search"]["words"]["global"]
-
+            
+	    print results["error"]["msg"]
             for cpt in xrange( results["search"]["words"]["global"]["nb_words"] ) :
                     this_word_info = results["search"]["words"][cpt + 1]
                     this_word_info["cpt"] = cpt + 1

=== modified file 'src/alfanous/Outputs.py'
--- src/alfanous/Outputs.py	2012-10-30 16:30:11 +0000
+++ src/alfanous/Outputs.py	2012-10-30 17:53:26 +0000
@@ -313,7 +313,7 @@
 		""" return suggestions """
 		query = flags["query"] if flags.has_key( "query" ) else self._defaults["flags"]["query"]
 		try:
-			output = self.QSE.suggest_all( unicode( query.replace( "\\", "" ), 'utf8' ) ).items()
+			output = self.QSE.suggest_all( unicode( query, 'utf8' ) ).items()
 		except Exception:
 			output = []
 		return {"suggest":output}
@@ -344,9 +344,14 @@
 		annotation_word = flags["annotation_word"] if flags.has_key( "annotation_word" ) else self._defaults["flags"]["annotation_word"]
 		fuzzy = flags["fuzzy"] if flags.has_key( "fuzzy" ) else self._defaults["flags"]["fuzzy"]
 
+		#preprocess query
+		query= query.replace( "\\", "") 
+		if not isinstance(query,unicode):
+			query = unicode( query , 'utf8' )
+
 		#Search
 		SE = self.FQSE if fuzzy else self.QSE
-		res, termz = SE.search_all( unicode( query.replace( "\\", "" ), 'utf8' ) , self._defaults["results_limit"], sortedby = sortedby )
+		res, termz = SE.search_all( query  , self._defaults["results_limit"], sortedby = sortedby )
 		terms = [term[1] for term in list( termz )] # TODO: I dont like this termz structure , must change it
 		terms_uthmani = map( STANDARD2UTHMANI, terms )
 		#pagination