← Back to team overview

team4alfanous team mailing list archive

[Branch ~team4alfanous/alfanous/alfanous-git] Rev 341: fix vocalizations transferring operation

 

------------------------------------------------------------
revno: 341
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Sat 2012-09-29 19:06:14 +0100
message:
  fix vocalizations transferring operation 
modified:
  Makefile
  src/alfanous-import/Transformer.py
  src/alfanous-import/main.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 'Makefile'
--- Makefile	2012-09-29 08:33:16 +0000
+++ Makefile	2012-09-29 18:06:14 +0000
@@ -129,13 +129,13 @@
 # 3. list of indexed translations, see update_translations_indexed_list
 # 4. list of offline recitations, see update_recitations_offline_list
 # 5. list of online recitations, see update_recitations_online_list  
-update_post_build:  update_information update_hints update_translations_indexed_list update_recitations_offline_list update_recitations_online_list    
+update_post_build:  update_dynamic_resources_postbuild  update_information update_hints update_translations_indexed_list update_recitations_offline_list update_recitations_online_list   
 
 ##  update resources that must be updated before indexing phase, which are:
 # 1. Quranic Arabic Corpus, see update_quranic_corpus
 # 2. Linguistic resources on the form of python dictionarries to accelerate the loading , see update_dynamic_resources
 # 3. List of translations to be downloaded, see  update_translations_to_download_list
-update_pre_build:  update_quranic_corpus update_dynamic_resources update_translations_to_download_list
+update_pre_build:  update_quranic_corpus update_dynamic_resources_prebuild update_translations_to_download_list
 
 # update information manually 
 update_information:
@@ -171,18 +171,21 @@
 update_recitations_online_list:
 	cd $(CONFIG_PATH); wget http://www.everyayah.com/data/recitations.js
 
-# update dynamic resources automatically , see transfer_all
-update_dynamic_resources: transfer_all
+# update dynamic resources automatically , see transfer_prebuild, transfer_postbuild
+update_dynamic_resources_prebuild: transfer_prebuild
+update_dynamic_resources_postbuild: transfer_postbuild
 	
-## build dynamic_resources by transferring the data from database to python modules, this include:
-# 1. arabic stop words, see transfer_stopwords
-# 2. Quranic words synonyms, see transfer_synonyms
-# 3. Word properties [root,type], see transfer_word_props
-# 4. Derivtion levels of Qurnic words, see transfer_derivations
-# 5. Field names mapping Arabic to English, see transfer_ara2eng_names
-# 6. Quranic words mapping Standard to Uthmani, see transfer_standard2uthmani
-# 7. Different vocalizations of each quranic word, see transfer_vocalizations
-transfer_all: transfer_stopwords transfer_synonyms transfer_word_props transfer_derivations transfer_ara2eng_names transfer_standard2uthmani transfer_vocalizations
+## build dynamic_resources by transferring the data from database (or indexes) to python modules, this include:
+# 1. [prebuild] arabic stop words, see transfer_stopwords
+# 2. [prebuild] Quranic words synonyms, see transfer_synonyms
+# 3. [prebuild] Word properties [root,type], see transfer_word_props
+# 4. [prebuild] Derivtion levels of Qurnic words, see transfer_derivations
+# 5. [prebuild] Field names mapping Arabic to English, see transfer_ara2eng_names
+# 6. [prebuild] Quranic words mapping Standard to Uthmani, see transfer_standard2uthmani
+# 7. [postbuild] Different vocalizations of each quranic word, see transfer_vocalizations
+transfer_all: transfer_prebuild transfer_postbuild
+transfer_prebuild: transfer_stopwords transfer_synonyms transfer_word_props transfer_derivations transfer_ara2eng_names transfer_standard2uthmani 
+transfer_postbuild: transfer_vocalizations
 	
 transfer_stopwords:
 	export PYTHONPATH=$(API_PATH) ;	python $(QIMPORT) -t stopwords $(DB_PATH)main.db $(DYNAMIC_RESOURCES_PATH)
@@ -197,7 +200,7 @@
 	export PYTHONPATH=$(API_PATH) ;	python $(QIMPORT) -t derivations $(DB_PATH)main.db $(DYNAMIC_RESOURCES_PATH)
 
 transfer_vocalizations:
-	export PYTHONPATH=$(API_PATH) ;	python $(QIMPORT) -t vocalizations $(DB_PATH)main.db $(DYNAMIC_RESOURCES_PATH)
+	export PYTHONPATH=$(API_PATH) ;	python $(QIMPORT) -t vocalizations $(DB_PATH)main.db $(INDEX_PATH)main/ $(DYNAMIC_RESOURCES_PATH)
 
 transfer_ara2eng_names:
 	export PYTHONPATH=$(API_PATH) ;	python $(QIMPORT) -t ara2eng_names $(DB_PATH)main.db $(DYNAMIC_RESOURCES_PATH)
@@ -207,8 +210,6 @@
 	
 
 
-
-
 ## build all indexes:
 # 1. Main index that contains all information related to Ayah or Surah, see index_main
 # 2. Extended index that contains Quranic translations and offline recitations, see index_extend

=== modified file 'src/alfanous-import/Transformer.py'
--- src/alfanous-import/Transformer.py	2012-06-13 22:12:59 +0000
+++ src/alfanous-import/Transformer.py	2012-09-29 18:06:14 +0000
@@ -396,17 +396,22 @@
         return raw_str
 
     def transfer_vocalizations( self ):
-        """ load indexed vocalized words  from the main index and save them as a list in a dynamic py """
-        QSE = QuranicSearchEngine( self.__ixpath )
-        mfw = QSE.most_frequent_words( 9999999, "aya_" )
-
-        V = QArabicSymbolsFilter( \
+        """ load indexed vocalized words  from the main index and save them as a list in a dynamic py """ 
+	QSE = QuranicSearchEngine( self.__ixpath )
+
+	if QSE.OK:
+		mfw = QSE.most_frequent_words( 9999999, "aya_" )
+	else:
+		mfw = []
+
+	V = QArabicSymbolsFilter( \
                                 shaping = False, \
                                 tashkil = True, \
                                 spellerrors = False, \
                                 hamza = False \
-                                ).normalize_all
+	).normalize_all
 
+	
 
         vocalization_dict = {}
         for w in mfw:

=== modified file 'src/alfanous-import/main.py'
--- src/alfanous-import/main.py	2012-06-23 18:35:53 +0000
+++ src/alfanous-import/main.py	2012-09-29 18:06:14 +0000
@@ -93,11 +93,16 @@
 
     if len( args ) == 2:
         SOURCE = args[0]
+	SOURCE2 = "." # Secondary source, used for main index path
         DESTINATION = args[1]
+    elif len( args ) == 3:
+        SOURCE = args[0]
+	SOURCE2 = args[1] # Secondary source, used for main index path
+        DESTINATION = args[2]
     else:
         parser.error( "Choose SOURCE_PATH and DISTINATION_PATH" )
 
-    T = Transformer( ixpath = ".", dypypath = DESTINATION, dbpath = SOURCE )
+    T = Transformer( ixpath = SOURCE2 , dypypath = DESTINATION, dbpath = SOURCE ) 
     if options.transfer == "stopwords":
         T.transfer_stopwords()
     elif options.transfer == "synonyms":
@@ -106,12 +111,12 @@
         T.transfer_word_props()
     elif options.transfer == "derivations":
         T.transfer_derivations()
-    elif options.transfer == "vocalizations":
-        T.transfer_vocalizations()
     elif options.transfer == "ara2eng_names":
         T.transfer_ara2eng_names()
     elif options.transfer == "std2uth_words":
         T.transfer_std2uth_words()
+    elif options.transfer == "vocalizations":
+        T.transfer_vocalizations()
 
 if options.speller: