Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
senpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
senpy
senpy
Commits
10f4782a
Commit
10f4782a
authored
Dec 01, 2014
by
J. Fernando Sánchez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better NIF compliance
parent
4351f76b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
16 deletions
+20
-16
plugins/sentiment140/__init__.py
plugins/sentiment140/__init__.py
+6
-2
senpy/blueprints.py
senpy/blueprints.py
+1
-1
senpy/context.jsonld
senpy/context.jsonld
+1
-0
senpy/extensions.py
senpy/extensions.py
+3
-10
senpy/models.py
senpy/models.py
+0
-2
senpy/plugins.py
senpy/plugins.py
+9
-1
No files found.
plugins/sentiment140/__init__.py
View file @
10f4782a
...
...
@@ -35,8 +35,12 @@ class Sentiment140Plugin(SentimentPlugin):
polarity
=
"marl:Positive"
elif
polarity_value
<
50
:
polarity
=
"marl:Negative"
entry
=
Entry
(
text
=
params
[
"input"
])
opinion
=
Opinion
(
hasPolarity
=
polarity
,
polarityValue
=
polarity_value
)
entry
=
Entry
(
text
=
params
[
"input"
],
prefix
=
params
.
get
(
"prefix"
,
""
))
opinion
=
Opinion
(
hasPolarity
=
polarity
,
polarityValue
=
polarity_value
,
prefix
=
params
.
get
(
"prefix"
,
""
))
opinion
[
"prov:wasGeneratedBy"
]
=
self
.
id
entry
.
opinions
.
append
(
opinion
)
entry
.
language
=
lang
response
.
entries
.
append
(
entry
)
...
...
senpy/blueprints.py
View file @
10f4782a
...
...
@@ -48,7 +48,7 @@ def get_params(req, params=BASIC_PARAMS):
if
alias
in
indict
:
outdict
[
param
]
=
indict
[
alias
]
if
param
not
in
outdict
:
if
options
.
get
(
"required"
,
False
):
if
options
.
get
(
"required"
,
False
)
and
"default"
not
in
options
:
wrong_params
[
param
]
=
params
[
param
]
else
:
if
"default"
in
options
:
...
...
senpy/context.jsonld
View file @
10f4782a
...
...
@@ -34,6 +34,7 @@
"@id": "dc:date",
"@type": "xsd:dateTime"
},
"text": { "@id": "nif:isString" },
"wnaffect": "http://www.gsi.dit.upm.es/ontologies/wnaffect#",
"xsd": "http://www.w3.org/2001/XMLSchema#"
}
senpy/extensions.py
View file @
10f4782a
...
...
@@ -9,11 +9,6 @@ logger = logging.getLogger(__name__)
from
.plugins
import
SentimentPlugin
,
EmotionPlugin
try
:
from
flask
import
_app_ctx_stack
as
stack
except
ImportError
:
from
flask
import
_request_ctx_stack
as
stack
from
.blueprints
import
nif_blueprint
from
git
import
Repo
,
InvalidGitRepositoryError
...
...
@@ -145,11 +140,9 @@ class Senpy(object):
@
property
def
plugins
(
self
):
""" Return the plugins registered for a given application. """
ctx
=
stack
.
top
if
ctx
is
not
None
:
if
not
hasattr
(
ctx
,
'senpy_plugins'
)
or
self
.
_outdated
:
ctx
.
senpy_plugins
=
self
.
_load_plugins
()
return
ctx
.
senpy_plugins
if
not
hasattr
(
self
,
'senpy_plugins'
)
or
self
.
_outdated
:
self
.
senpy_plugins
=
self
.
_load_plugins
()
return
self
.
senpy_plugins
def
filter_plugins
(
self
,
**
kwargs
):
""" Filter plugins by different criteria """
...
...
senpy/models.py
View file @
10f4782a
...
...
@@ -80,7 +80,6 @@ class Opinion(Leaf):
opinionContext
=
{}
def
__init__
(
self
,
polarityValue
=
None
,
hasPolarity
=
None
,
*
args
,
**
kwargs
):
super
(
Opinion
,
self
).
__init__
(
context
=
self
.
opinionContext
,
prefix
=
"marl"
,
*
args
,
**
kwargs
)
if
polarityValue
is
not
None
:
...
...
@@ -95,7 +94,6 @@ class EmotionSet(Leaf):
if
not
emotions
:
emotions
=
[]
super
(
EmotionSet
,
self
).
__init__
(
context
=
self
.
emotionContext
,
prefix
=
"onyx"
,
*
args
,
**
kwargs
)
self
.
emotions
=
emotions
or
[]
senpy/plugins.py
View file @
10f4782a
...
...
@@ -25,6 +25,10 @@ PARAMS = {"input": {"aliases": ["i", "input"],
"required"
:
False
,
"options"
:
[
"es"
,
"en"
],
},
"prefix"
:
{
"aliases"
:
[
"prefix"
,
"p"
],
"required"
:
True
,
"default"
:
""
,
},
"urischeme"
:
{
"aliases"
:
[
"urischeme"
,
"u"
],
"required"
:
False
,
"default"
:
"RFC5147String"
,
...
...
@@ -56,9 +60,13 @@ class SenpyPlugin(object):
def
disable
(
self
):
self
.
enabled
=
False
@
property
def
id
(
self
):
return
"{}_{}"
.
format
(
self
.
name
,
self
.
version
)
def
jsonable
(
self
,
parameters
=
False
):
resp
=
{
"@id"
:
"{}_{}"
.
format
(
self
.
name
,
self
.
version
)
,
"@id"
:
self
.
id
,
"enabled"
:
self
.
enabled
,
}
if
hasattr
(
self
,
"repo"
)
and
self
.
repo
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment