forked from EKT1/valence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
valence.py
executable file
·36 lines (28 loc) · 936 Bytes
/
valence.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
"""The :mod:`valence` contains text valence related methods."""
import os
import cgi
from ekorpus.lib.base import *
from valencecolor import marktext
class ValenceController(BaseController):
def index(self):
"""Generates the text input form."""
return render('/valence/valence.mak')
def color(self):
"""Count and mark with a color the valence keywords."""
p = request.params
dataonly=""
if 'dataonly' in p:
dataonly = p['dataonly']
lexiconbased=""
if 'lexiconbased' in p:
lexiconbased = p['lexiconbased']
if ('text' in p) and p['text']:
c.text=marktext(p['text'], dataonly, lexiconbased)
else:
c.text = "Nothing"
if dataonly:
return c.text
else:
c.lexiconbased = lexiconbased
return render('/valence/colored.mak')