[0adbe8b] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | """ |
---|
| 3 | Sistema de Modelado de Tópicos |
---|
| 4 | |
---|
| 5 | Copyleft (@) 2014 CENDITEL nodo Mérida - https://planificacion.cenditel.gob.ve/trac/ |
---|
| 6 | """ |
---|
| 7 | ## @package django_topic_explorer.utils |
---|
| 8 | # |
---|
| 9 | # Métodos para correr el lda |
---|
| 10 | # @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
| 11 | # @author <a href='http://www.cenditel.gob.ve'>Centro Nacional de Desarrollo e Investigación en TecnologÃas Libres |
---|
| 12 | # (CENDITEL) nodo Mérida - Venezuela</a> |
---|
| 13 | # @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 14 | # @version 1.3 |
---|
| 15 | from subprocess import Popen |
---|
| 16 | |
---|
| 17 | def call_lda(command): |
---|
| 18 | """! |
---|
| 19 | Función para llamar al proceso del LDA |
---|
| 20 | |
---|
| 21 | @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
| 22 | @copyright GNU/GPLv2 |
---|
| 23 | @date 09-02-2017 |
---|
| 24 | @param command Recibe el comando a ejecutar |
---|
| 25 | @return output Retorna la salida del subproceso |
---|
| 26 | """ |
---|
| 27 | print command |
---|
| 28 | p = Popen(command) |
---|
| 29 | |
---|
| 30 | output, errs = p.communicate() |
---|
| 31 | |
---|
| 32 | if errs < 0: |
---|
| 33 | return "ERROR: FALLÃ EJECUCIÃN DE LDA" |
---|
| 34 | return output |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | def generate_comand(base_dir,corpus_path,filename,topics_number): |
---|
| 38 | """! |
---|
| 39 | Función para generar los procesos del LDA |
---|
| 40 | |
---|
| 41 | @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
| 42 | @copyright GNU/GPLv2 |
---|
| 43 | @date 09-02-2017 |
---|
| 44 | @param base_dir Recibe la ruta base |
---|
| 45 | @param corpus_path Recibe la ruta del corpus.dat |
---|
| 46 | @param filename Recibe el nombre con el que se generará el directorio |
---|
| 47 | @param topics_number Recibe el número de tópicos |
---|
| 48 | """ |
---|
| 49 | settings_path = base_dir+'/utils/lda/settings.txt' |
---|
| 50 | lda_exe = base_dir+'/utils/lda/lda' |
---|
| 51 | name = filename.split("/")[-1] |
---|
| 52 | filename = filename+"/lda/"+name |
---|
| 53 | for i in range(1,topics_number+1): |
---|
| 54 | command = "{0} est 0.1 {1} {2} {3} random {4}{1}".format(lda_exe,i*10,settings_path,corpus_path,filename) |
---|
| 55 | call_lda(command.split(" ")) |
---|