Commit e4aa5242 authored by matjaz's avatar matjaz

Latino project totally reconstructed - due to visualStudio developement integration.

parent 6b84e14d
This diff is collapsed.
import logging
import sys
from settings import *
#------------------------------------------------------------------------------
# prepare environment for loading latino (Python.net interpreter should be used)
# see: http://pythonnet.sourceforge.net/
#------------------------------------------------------------------------------
sys.path.append(package_bin)
try:
from LatinoCloudFlows import *
import System
import Latino
except Exception:
logging.warning("LatinoClowdFlows could not be imported! Either there are no Latino dll available or a "\
"wrong interpreter is used. See 'http://pythonnet.sourceforge.net' for interpreter details. "\
"Other functionality (besides latino) will work as .")
pass
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
from serialization_utils import *
#------------------------------------------------------------------------------
# VISUALISATIONS
#------------------------------------------------------------------------------
def show_adc(input_dict):
if input_dict["adc"] == None:
raise Exception("Input ADC is required for displaying Anotated Document Corpus!")
return {}
def show_clusters(input_dict):
return {}
def show_classifications(input_dict):
return {}
def advanced_object_viewer(input_dict):
return {}
def show_table(input_dict):
return {}
#------------------------------------------------------------------------------
# SUPPLEMENTARY FUNCTIONS
#------------------------------------------------------------------------------
def split_object(input_dict):
output_dict = {}
obj = input_dict['object']
output_dict['object'] = eval("obj"+input_dict['attribute'])
return output_dict
def python_snippet(input_dict):
output_dict = {}
input = input_dict['in']
for (i, val) in enumerate(input):
vars()["in"+str(i+1)] = val
out1 = None
exec(input_dict['pycode'])
output_dict['out'] = out1
return output_dict
def create_range(input_dict):
rng = range(ToInt(input_dict['start']), ToInt(input_dict['stop']), ToInt(input_dict['step']))
return {'range':rng }
def compare_lists(input_dict):
l1 = input_dict['list1']
l2 = input_dict['list2']
l = min(len(l1),len(l2))
cntEq = 0
for i in range(0,l):
if l1[i]==l2[i]:
cntEq += 1
return {
'accuracy':(0.0+cntEq)/l,
'statistics':{
'elements':l,
'equal':cntEq,
'different':l-cntEq,
'accuracy':(0.0+cntEq)/l,
'error':(0.0+l-cntEq)/l,
}
}
import os
package_name = 'latino'
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
......@@ -4,32 +4,27 @@ from django.http import Http404, HttpResponse
# modeli
from workflows.models import *
# auth fore
from django.contrib.auth.decorators import login_required
# latino
import latino
import logging
@login_required
def get_adc_index(request, widget_id, narrow_doc = 'n', document_id_from=0, document_id_to=-1):
logging.info('__get_adc_index__')
w = get_object_or_404(Widget, pk=widget_id)
if w.workflow.user == request.user:
firstInput = w.inputs.all()[0]
adc = firstInput.value
return latino.makeAdcIndexPage(adc, document_id_from, document_id_to, narrow_doc=='n')
data = adc.netObj.MakeIndexPage(document_id_from, document_id_to, 100, narrow_doc)
return HttpResponse(data, mimetype='text/html')
else:
return HttpResponse(status=400)
@login_required
def get_adc_page(request, widget_id, document_id, narrow_doc = 'n'):
logging.info('__get_adc_page__')
w = get_object_or_404(Widget, pk=widget_id)
if w.workflow.user == request.user:
firstInput = w.inputs.all()[0]
adc = firstInput.value
return latino.makeAdcDocPage(adc, document_id, narrow_doc)
data = adc.netObj.MakeDocumentPage(document_id, narrow_doc)
return HttpResponse(data, mimetype='text/html')
else:
return HttpResponse(status=400)
\ No newline at end of file
return HttpResponse(status=400)
from django.shortcuts import render
#latino
import os
import latino
import logging
from serialization_utils import *
import django.template.loader
def show_adc(request,input_dict,output_dict,widget):
logging.info('__show_adc__VIEW__')
return latino.adcView(request,input_dict,output_dict,widget)
view = django.shortcuts.render(request, 'visualizations/adc.html', {'widget': widget,
'input_dict': input_dict,
'output_dict': output_dict})
return view
def show_clusters(request,input_dict,output_dict,widget):
return {}
def show_classifications(request,input_dict,output_dict,widget):
return {}
def advanced_object_viewer(request,input_dict,output_dict,widget):
logging.info('__advanced_object_viewer__VIEW__')
import objectPprint as opp
obj = input_dict['object']
maxStringLen = latino.ToInt(input_dict['maxStringLen'])
obj = input_dict['obj']
maxStringLen = ToInt(input_dict['maxStringLen'])
objstr = ""
if input_dict.has_key('attribute') and input_dict['attribute']!="":
try:
......@@ -29,5 +33,6 @@ def advanced_object_viewer(request,input_dict,output_dict,widget):
return render(request, 'visualizations/advanced_object_viewer.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict})
def show_table(request,input_dict,output_dict,widget):
logging.info('__show_table__VIEW__')
return latino.ShowTable(request,input_dict,output_dict,widget)
\ No newline at end of file
tbl= input_dict['tbl']
output_dict = {'attrs':list(tbl.items()[0][0]), 'metas':[], 'data':tbl.values()[0], 'title':'Vocabulary Table'}
return render(request, 'visualizations/table_viewer.html',{'widget':widget,'input_dict':input_dict,'output_dict':output_dict})
\ No newline at end of file
......@@ -9,6 +9,8 @@ from workflows import packageLibImporter
def setattr_local(name, value, package):
setattr(sys.modules[__name__], name, value)
packageLibImporter.importAllPackagesLib("library",setattr_local)
from latino.library import *
def test_interaction(input_dict):
return input_dict
......
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