Conjunto fb25bf8 en modelado_topicos
- Fecha y hora:
- 12/06/2015 09:47:58 (hace 9 años)
- Branches:
- master, preprocesamiento, v1.0
- Children:
- ff807e0
- Parents:
- 27c3620
- Ficheros:
-
- 1 añadido
- 4 editados
Leyenda
- No modificado
- Añadido
- Eliminado
-
django_topic_explorer/settings.py
r1d65e92 rfb25bf8 95 95 ## TOPIC EXPLORER SETTINGS 96 96 TOPIC_EXPLORER_PATH = '/home/jredondo/Proyectos/Analisis_del_Discurso/src/topic-explorer/' 97 PATH = TOPIC_EXPLORER_PATH + 'demo-data/ap/../models/' 98 CORPUS_FILE = TOPIC_EXPLORER_PATH + 'demo-data/ap/../models/ap-nltk-en-freq5.npz' 99 MODEL_PATTERN = TOPIC_EXPLORER_PATH + 'demo-data/ap/../models/ap-nltk-en-freq5-LDA-K{0}-document-20.npz' 100 #PATH = TOPIC_EXPLORER_PATH + 'demo-data/programapatrio_propuestas_descripcion/../models/' 101 #CORPUS_FILE = TOPIC_EXPLORER_PATH + 'demo-data/programapatrio_propuestas_descripcion/../models/programapatrio_propuestas_descripcion-nltk-en-freq5.npz' 102 #MODEL_PATTERN = TOPIC_EXPLORER_PATH + 'demo-data/programapatrio_propuestas_descripcion/../models/programapatrio_propuestas_descripcion-nltk-en-freq5-LDA-K{0}-document-20.npz' 97 MODELS_PATH = TOPIC_EXPLORER_PATH + 'demo-data/programapatrio_propuestas_descripcion/../models/' 98 CORPUS_FILE = MODELS_PATH + 'programapatrio_propuestas_descripcion-nltk-en-freq5.npz' 99 MODEL_PATTERN = TOPIC_EXPLORER_PATH + 'demo-data/ap/../models/programapatrio_propuestas_descripcion-nltk-en-freq5-LDA-K{0}-document-20.npz' 103 100 CONTEXT_TYPE = 'document' 104 #PORT = '16{0:03d}'105 #HOST = '0.0.0.0'106 101 TOPICS = '10, 20, 30, 40, 50, 60, 70, 80, 90, 100' 107 102 CORPUS_NAME = 'Deafult' 108 103 ICONS = 'link' 109 #path = 'logs/aux/{0}.log'110 104 111 105 CORPUS_LINK = None … … 113 107 DOC_TITTLE_FORMAT = None 114 108 DOC_URL_FORMAT = None 115 #TOPICS = None116 117 #DEFAULT_K = 50118 109 119 110 -
topic_explorer/static/topic_explorer/js/icons.js
rc617763 rfb25bf8 12 12 .attr("xlink:href","/static/topic_explorer/img/link.png") 13 13 .attr("class", "linkIcon icon") 14 //.on("click", function(d) { window.location.href = "/?doc=" + encodeURIComponent(d);});15 14 .on("click", function(d) { window.location.href = "topic_explorer/doc/" + encodeURIComponent(d);}); 16 15 }, -
topic_explorer/templates/index.html
rc617763 rfb25bf8 15 15 <script src="{% static "topic_explorer/js/icons.js" %}"></script> 16 16 <link rel="stylesheet" type="text/css" href="{% static "topic_explorer/bootstrap-2.3.2/css/bootstrap.min.css" %}"/> 17 <!--<link rel="stylesheet" type="text/css" href="style.css" />--> 18 <style> 19 .y.axis text { 20 visibility: hidden; 21 } 22 .y.axis g .icon { 23 opacity: 0; 24 } 25 .y.axis g:hover .icon { 26 opacity: 1.0; 27 } 28 29 .y.axis text, .y.axis image { 30 cursor: pointer; 31 } 32 .y.axis rect:hover { 33 stroke: #fff; 34 stroke-width: 0; 35 opacity: 0 !important; 36 } 37 .y.axis rect:hover .icon { 38 opacity: 1 !important; 39 } 40 41 .docLabel { 42 } 43 44 .bar { 45 fill: steelblue; 46 } 47 48 .bar:hover { 49 fill: brown; 50 } 51 52 .axis { 53 font: 11px sans-serif; 54 } 55 56 .axis path, 57 .axis line { 58 fill: none; 59 stroke: #000; 60 shape-rendering: crispEdges; 61 } 62 .docLabel{ 63 font:11px sans-serif; 64 pointer-events: none; 65 } 66 67 rect { 68 opacity: 0.6; 69 } 70 71 rect.hover { 72 stroke: #000; 73 stroke-width: 1; 74 shape-rendering: crispEdges; 75 cursor: crosshair; 76 } 77 78 rect.hover, .legend rect { 79 opacity: 0.8; 80 } 81 .doc:hover rect, .doc.hover rect { 82 opacity: 1.0; 83 } 84 rect:hover { 85 opacity: 1.0 !important; 86 } 87 rect:hover, .legend.hover rect, .legend.selected rect { 88 stroke: #000; 89 stroke-width: 2; 90 shape-rendering: crispEdges; 91 } 92 .selected text, .hover text { 93 font-weight: bold; 94 } 95 #legend, #controls { 96 position: absolute; 97 overflow: visible; 98 } 99 .primary { 100 text-transform: uppercase; 101 } 102 text.hover, .title{ 103 font-weight: bold; 104 } 105 /* 106 .primary.doc:hover, .primary.doc { 107 stroke: #000; 108 stroke-width: 1px; 109 stroke-opacity: 1.0; 110 shape-rendering: crispEdges; 111 }*/ 112 .logo-word { 113 background-image: url('/img/inpho_logo.png'); 114 background-size: 172px 92px; 115 width: 172px; 116 height: 84px; 117 padding-top: 6px; 118 margin-top: 14px; 119 margin-bottom: 15px; 120 margin-left: -6px; 121 display: inline-block; 122 text-indent: -3000px; 123 } 124 h1 { 125 text-align: center; 126 margin-bottom: 0; 127 font-size: 59px; 128 line-height: 1; 129 color: inherit; 130 letter-spacing: -1px; 131 132 } 133 h1 a, h1 a:hover { 134 color: #000; 135 text-decoration: none; 136 } 137 138 .btn { 139 vertical-align: middle; 140 margin-top: 2px; 141 } 142 #twitter-widget-0 { 143 margin-bottom: -11px; 144 } 145 .null, .non-null { 146 display: none; 147 } 148 .formula { 149 font-variant: small-caps; 150 } 151 .formula em { 152 font-variant: normal; 153 } 154 155 .popover-content { 156 max-height: 250px; 157 overflow-y: scroll; 158 } 159 160 </style> 17 <link rel="stylesheet" type="text/css" href="{% static "topic_explorer/css/topic_explorer.css" %}"/> 18 161 19 </head> 162 20 … … 170 28 <div class="input-append"> 171 29 <input type="hidden" name="doc" id="hidden_id"> 172 <input type="text" id="doc" class="typeahead input-xlarge" placeholder="Document " autocomplete="off">30 <input type="text" id="doc" class="typeahead input-xlarge" placeholder="Documento" autocomplete="off"> 173 31 <button class="btn" type="button" id="randomDoc"><span class="icon-random"></span></button> 174 32 </div> 175 33 <div class="btn-group"> 176 <button type=" submit" id="submit" class="btn">Visualize</button>34 <button type="button" id="submit" class="btn" >Visualizar</button> 177 35 <a class="btn dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></a> 178 36 <ul class="dropdown-menu"> … … 257 115 var url = "{0}//{1}:8000/topic_explorer/doc/{2}/".format(window.location.protocol, window.location.hostname, k); 258 116 259 /*url += "?doc=" + encodeURIComponent($("#hidden_id").val() || docid) ;*/260 117 url += encodeURIComponent($("#hidden_id").val() || docid) ; 261 118 window.location = url; … … 312 169 <div id="chart"> </div> 313 170 <div id="controls" style="display:none;"> 314 <strong> Display Options</strong>315 <label class="checkbox"><input class="sort" type="checkbox"> Alphabetical sort</label>316 <label class="checkbox"><input class="scale" type="checkbox"> Normaliz e topic bars</label>317 <button class="btn reset" onclick="resetTopicSort()" disabled>Reset Topic Sort</button><br>318 <button class="btn topdoc" style="display:none">Top Documents for[Topic]</button>171 <strong>Opciones</strong> 172 <label class="checkbox"><input class="sort" type="checkbox"> Orden alfabético</label> 173 <label class="checkbox"><input class="scale" type="checkbox"> Normalizar barras de tópicos</label> 174 <button class="btn reset" type="button" onclick="resetTopicSort()" disabled>Restaurar orden de tópicos</button><br> 175 <button class="btn topdoc" type='button' style="display:none">Ordenar documentos para tópico [Topic]</button> 319 176 </div> 320 177 … … 437 294 return false; 438 295 } 439 $('#submit').text(d3.keys(topics).length + ' T opicos');296 $('#submit').text(d3.keys(topics).length + ' Tópicos'); 440 297 441 298 … … 475 332 .selectAll("text") 476 333 .attr("class", function(d) { return (d == docid && roottopic != null) ? "primary" : "" }) 477 //.on("click", function(d) { window.location.href = "/?doc=" + d;})478 334 .on("click", function(d) { window.location.href = "topic_explorer/doc/" + d;}) 479 335 … … 768 624 $('.topdoc').text('Top Documents for Topic ' + topic); 769 625 $('.topdoc').show(); 770 //$('.topdoc').click(function URL() { location.href = location.origin + '?topic=' + topic;});771 $('.topdoc').click(function URL() { location.href = location.origin + '/topic_explorer/topic/{{k_param}}/' + topic;});626 //$('.topdoc').click(function URL() {console.log("COMETNTADO"); location.href = location.origin + '?topic=' + topic;}); 627 $('.topdoc').click(function URL() {console.log("ACTIVO"); location.href = location.origin + '/topic_explorer/topic/{{k_param}}/' + topic;}); 772 628 $('.topdoc').mouseenter(function() { 773 629 $('.legend rect').not('.top_' + topic).tooltip('hide'); -
topic_explorer/views.py
rc617763 rfb25bf8 15 15 16 16 17 path = settings.PATH17 #path = settings.PATH 18 18 corpus_file = settings.CORPUS_FILE 19 19 context_type = settings.CONTEXT_TYPE … … 22 22 corpus_name = settings.CORPUS_NAME 23 23 icons = settings.ICONS 24 #path = 'logs/aux/{0}.log'25 24 26 25 corpus_link = settings.CORPUS_LINK 27 #topic_range = settings.TOPIC_RANGE28 26 topics_range = [int(item) for item in settings.TOPICS.split(',')] 29 27 doc_title_format = settings.DOC_TITTLE_FORMAT … … 47 45 return HttpResponseServerError(str(exc_value)) 48 46 49 # Create your views here.50 47 51 48 def doc_topic_csv(request, doc_id): 52 #response.content_type = 'text/csv; charset=UTF8'53 54 49 data = lda_v.doc_topics(doc_id) 55 50 … … 62 57 63 58 def doc_csv(request, doc_id, threshold=0.2): 64 #response.content_type = 'text/csv; charset=UTF8'65 66 59 data = lda_v.sim_doc_doc(doc_id) 67 60 … … 77 70 lda_m = LCM.load(model_pattern.format(k_param)) 78 71 lda_v = LDAViewer(lda_c, lda_m) 79 #response.content_type = 'application/json; charset=UTF8'80 72 try: 81 73 N = int(request.query.n) … … 106 98 except: 107 99 pass 108 109 #response.content_type = 'application/json; charset=UTF8'110 111 100 if N > 0: 112 101 data = lda_v.dist_doc_doc(doc_id)[:N] … … 130 119 def topics(request): 131 120 try: 132 #response.content_type = 'application/json; charset=UTF8'133 #response.set_header('Expires', _cache_date())134 135 121 # populate entropy values 136 122 data = lda_v.topic_oscillations() … … 157 143 158 144 def docs(request): 159 #response.content_type = 'application/json; charset=UTF8'160 #response.set_header('Expires', _cache_date())161 145 try: 162 146 docs = lda_v.corpus.view_metadata(context_type)[doc_label_name(context_type)]
Nota: Vea TracChangeset
para ayuda en el uso del visor de conjuntos de cambios.