source: consulta_publica/utils/run_lda.py

baseconstituyenteestudiantesgeneralplan_patriasala
Last change on this file was 0ff122b, checked in by rudmanmrrod <rudman22@…>, 7 años ago

Agregado módulo de gestión de perfiles de procesamiento, incorporado el módulo de visualización de modelado de tópicos

  • Propiedad mode establecida a 100644
File size: 1.8 KB
Línea 
1# -*- coding: utf-8 -*-
2"""
3Sistema de Modelado de Tópicos
4
5Copyleft (@) 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
15from subprocess import Popen
16
17def 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
37def 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(" "))
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.