Commit b5500b7a authored by Anze Vavpetic's avatar Anze Vavpetic

fixed package structures for the following packages: nlp, decision support,...

fixed package structures for the following packages: nlp, decision support, subgroup discovery, bioinformatics.
parent eace9f79
...@@ -171,6 +171,10 @@ if USE_CONCURRENCY: ...@@ -171,6 +171,10 @@ if USE_CONCURRENCY:
'south', 'south',
'workflows', 'workflows',
'workflows.latino', 'workflows.latino',
'workflows.decision_support',
'workflows.bioinformatics',
'workflows.subgroup_discovery',
'workflows.nlp',
'website', 'website',
'signuplogin', 'signuplogin',
'django_extensions', 'django_extensions',
...@@ -190,6 +194,7 @@ else: ...@@ -190,6 +194,7 @@ else:
'south', 'south',
'workflows', 'workflows',
'workflows.latino', 'workflows.latino',
'workflows.decision_support',
'website', 'website',
'signuplogin', 'signuplogin',
'django_extensions', 'django_extensions',
......
import os
package_name = 'bioinformatics'
package_root = os.path.dirname(__file__)
package_statics = os.path.join(os.path.dirname(__file__), 'static', package_name)
package_bin = os.path.join(package_root, 'bin')
auto_update_db = True
create_backups = True
import os
package_name = 'decision_support'
package_root = os.path.dirname(__file__)
package_statics = os.path.join(os.path.dirname(__file__), 'static', package_name)
package_bin = os.path.join(package_root, 'bin')
auto_update_db = True
create_backups = True
import sys import sys
from django.shortcuts import render from django.shortcuts import render
from decision_support.interaction import *
from subgroup_discovery.interaction import *
from workflows import packageLibImporter from workflows import packageLibImporter
def setattr_local(name, value, package): def setattr_local(name, value, package):
......
from workflows.security import safeOpen from workflows.security import safeOpen
import nlp
import cPickle import cPickle
import json import json
import sys import sys
from decision_support.library import *
from subgroup_discovery.library import *
from workflows import packageLibImporter from workflows import packageLibImporter
def setattr_local(name, value, package): def setattr_local(name, value, package):
...@@ -807,47 +804,6 @@ def odt_to_arff(input_dict): ...@@ -807,47 +804,6 @@ def odt_to_arff(input_dict):
f = toARFFstring(input_dict['odt']) f = toARFFstring(input_dict['odt'])
output_dict['arff'] = f.getvalue() output_dict['arff'] = f.getvalue()
return output_dict return output_dict
# NLP tools
def merge_sentences(input_dict):
"""
Merges the input sentences in XML according to the specified method.
"""
method = input_dict['method']
merged_sen, id_to_sent = set(), {}
ids_list = []
for sentsXML in input_dict['sentences']:
sents = nlp.parse_def_sentences(sentsXML)
ids = set(map(lambda x: x['id'], sents))
ids_list.append(ids)
# Save the map from id to sentence
for sent in sents:
id_to_sent[sent['id']] = sent
if len(merged_sen) == 0:
merged_sen = ids
if method == 'union':
merged_sen = merged_sen | ids
elif method == 'intersection':
merged_sen = merged_sen & ids
elif method == 'intersection_two':
for ids_alt in ids_list:
merged_sen = merged_sen | (ids_alt & ids)
return {'merged_sentences' : nlp.sentences_to_xml([id_to_sent[sid] for sid in merged_sen])}
def load_corpus(input_dict):
'''
Parses an input file and encodes it in base 64.
'''
import os.path
import base64
f = safeOpen(input_dict['file'])
fname = os.path.basename(input_dict['file'])
data = base64.b64encode(f.read())
from services.webservice import WebService
ws = WebService('http://bodysnatcher.ijs.si:8092/totale?wsdl', 600)
response = ws.client.parseFile(fileName=fname, inFile=data)
return {'corpus' : response['parsedFile']}
def string_to_file(input_dict): def string_to_file(input_dict):
return {} return {}
......
import nlp
import os.path
import base64
from services.webservice import WebService
def merge_sentences(input_dict):
"""
Merges the input sentences in XML according to the specified method.
"""
method = input_dict['method']
merged_sen, id_to_sent = set(), {}
ids_list = []
for sentsXML in input_dict['sentences']:
sents = nlp.parse_def_sentences(sentsXML)
ids = set(map(lambda x: x['id'], sents))
ids_list.append(ids)
# Save the map from id to sentence
for sent in sents:
id_to_sent[sent['id']] = sent
if len(merged_sen) == 0:
merged_sen = ids
if method == 'union':
merged_sen = merged_sen | ids
elif method == 'intersection':
merged_sen = merged_sen & ids
elif method == 'intersection_two':
for ids_alt in ids_list:
merged_sen = merged_sen | (ids_alt & ids)
return {'merged_sentences' : nlp.sentences_to_xml([id_to_sent[sid] for sid in merged_sen])}
def load_corpus(input_dict):
'''
Parses an input file and encodes it in base 64.
'''
f = safeOpen(input_dict['file'])
fname = os.path.basename(input_dict['file'])
data = base64.b64encode(f.read())
ws = WebService('http://bodysnatcher.ijs.si:8092/totale?wsdl', 600)
response = ws.client.parseFile(fileName=fname, inFile=data)
return {'corpus' : response['parsedFile']}
import os
package_name = 'nlp'
package_root = os.path.dirname(__file__)
package_statics = os.path.join(os.path.dirname(__file__), 'static', package_name)
package_bin = os.path.join(package_root, 'bin')
auto_update_db = True
create_backups = True
import nlp
def definition_sentences_viewer(request, input_dict, output_dict, widget):
"""
Parses the input XML and displays the definition sentences given as input.
@author: Anze Vavpetic, 2012
"""
sentences = nlp.parse_def_sentences(input_dict['candidates'])
return render(request, 'visualizations/def_sentences.html',{'widget' : widget, 'sentences' : sentences})
def term_candidate_viewer(request, input_dict, output_dict, widget):
"""
Parses the input and displays the term candidates.
@author: Anze Vavpetic, 2012
"""
terms = []
for line in input_dict['candidates'].split('\n'):
try:
score, cand, lemma = line.split('\t')
except:
continue
terms.append({'score' : score,
'cand' : cand.replace('[', '').replace(']',''),
#'lemma' : lemma.replace('<<', '').replace('>>','')
})
terms = sorted(terms, key = lambda x: x['score'], reverse=True)
return render(request, 'visualizations/terms.html', {'widget' : widget, 'terms' : terms})
...@@ -3,14 +3,14 @@ Subgroup discovery library functions. ...@@ -3,14 +3,14 @@ Subgroup discovery library functions.
@author: Anze Vavpetic <anze.vavpetic@ijs.si> @author: Anze Vavpetic <anze.vavpetic@ijs.si>
''' '''
import json
import logging
try: try:
import json
from SubgroupDiscovery.SD_learner_classifier import SD_learner from SubgroupDiscovery.SD_learner_classifier import SD_learner
from SubgroupDiscovery.SDRule import SDRules from SubgroupDiscovery.SDRule import SDRules
import Orange import Orange
except: except:
pass print logging.warning('Could not import subgroup discovery orange package.')
class SubgroupDiscovery: class SubgroupDiscovery:
# Available algorithms and their parameters # Available algorithms and their parameters
......
import os
package_name = 'subgroup_discovery'
package_root = os.path.dirname(__file__)
package_statics = os.path.join(os.path.dirname(__file__), 'static', package_name)
package_bin = os.path.join(package_root, 'bin')
auto_update_db = True
create_backups = True
<div id="widgetinteract-{{widget.pk}}" rel="{{widget.pk}}" class="widgetinteractdialog" title="{{widget.name}} interaction" width="700" height="600">
<div>
Use the sliders to adjust the weights.<br><br>
<form>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="weightSel{{widget.pk}}">
<thead>
<tr>
<th>Attribute</th>
<th>Smaller attribute values are better</th>
<th>Weight</th>
<th>Weight (numeric)</th>
</tr>
</thead>
<tbody>
{% for att in attributes %}
<tr>
<td>
{{att}}
</td>
<td>
<input id="smallerIsBetter{{widget.pk}}{{att}}" name="smallerIsBetter{{widget.pk}}{{att}}" type="checkbox" value="true" style="display:inline;" />
</td>
<td>
<div style="width:200px;" id="slider{{widget.pk}}{{att}}"></div>
<script type="text/javascript">
// Slider code.
$("#slider{{widget.pk}}{{att}}").slider({
value:0,
min:0,
max:100,
slide: function( event, ui ) {
$( "#weight{{widget.pk}}{{att}}").val( $("#slider{{widget.pk}}{{att}}").slider("value") );
},
stop: function ( event, ui ) {
$( "#weight{{widget.pk}}{{att}}").val( $("#slider{{widget.pk}}{{att}}").slider("value") );
}
});
// Change the slider position when manually editing the weight.
$("#weight{{widget.pk}}{{att}}").change(function() {
$("#slider{{widget.pk}}{{att}}").slider("value", $("#weight{{widget.pk}}{{att}}").val());
});
</script>
</td>
<td>
<input type="number" style="width:30px; display:inline;" name="weight{{widget.pk}}{{att}}" id="weight{{widget.pk}}{{att}}" value="0"/>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<input type="hidden" name="widget_id" value="{{widget.pk}}"/>
</form>
<br/>
<button id="normalizeButton{{widget.pk}}">Normalize weights!</button>
<button id="resetButton{{widget.pk}}">Reset!</button>
<script type="text/javascript">
// Data table code.
$('#weightSel{{widget.pk}}').dataTable( {
"bJQueryUI": true,
"bPaginate" : false,
"bSort" : false,
"bFilter" : false
});
// Normalization code.
$("#normalizeButton{{widget.pk}}").button().click(function() {
var weight_elements = $('[id^="weight{{widget.pk}}"]');
var weight_sum = 0;
weight_elements.each(function(index) {
weight_sum += parseFloat($(this).val());
});
if (weight_sum > 0) {
weight_elements.each(function(index) {
//round(100 * parseFloat($(this).val()) / weight_sum)
$(this).val(Math.round(100 * parseFloat($(this).val()) / weight_sum));
$(this).change();
});
}
});
// Reset button code.
$("#resetButton{{widget.pk}}").button().click(function() {
$('[id^="weight{{widget.pk}}"]').each(function() {
$(this).val(0);
$(this).change();
});
});
</script>
</div>
</div>
\ No newline at end of file
import sys import sys
from django.shortcuts import render from django.shortcuts import render
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
import nlp
from decision_support.visualization import *
from subgroup_discovery.visualization import *
from workflows import packageLibImporter from workflows import packageLibImporter
def setattr_local(name, value, package): def setattr_local(name, value, package):
...@@ -194,34 +191,3 @@ def sdmsegs_viewer(request,input_dict,output_dict,widget): ...@@ -194,34 +191,3 @@ def sdmsegs_viewer(request,input_dict,output_dict,widget):
} }
output_dict = {'json_output':output} output_dict = {'json_output':output}
return render(request, 'visualizations/sdmsegs_viewer.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict}) return render(request, 'visualizations/sdmsegs_viewer.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict})
def definition_sentences_viewer(request, input_dict, output_dict, widget):
"""
Parses the input XML and displays the definition sentences given as input.
@author: Anze Vavpetic, 2012
"""
sentences = nlp.parse_def_sentences(input_dict['candidates'])
return render(request, 'visualizations/def_sentences.html',{'widget' : widget, 'sentences' : sentences})
def term_candidate_viewer(request, input_dict, output_dict, widget):
"""
Parses the input and displays the term candidates.
@author: Anze Vavpeltic, 2012
"""
terms = []
for line in input_dict['candidates'].split('\n'):
try:
score, cand, lemma = line.split('\t')
except:
continue
terms.append({'score' : score,
'cand' : cand.replace('[', '').replace(']',''),
#'lemma' : lemma.replace('<<', '').replace('>>','')
})
terms = sorted(terms, key = lambda x: x['score'], reverse=True)
return render(request, 'visualizations/terms.html', {'widget' : widget, 'terms' : terms})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment