Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
web-openccg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ease-ph
DeepLanguageUnderstanding
web-openccg
Commits
cf7a5d39
Unverified
Commit
cf7a5d39
authored
6 years ago
by
Sebastian Höffner
Browse files
Options
Downloads
Patches
Plain Diff
Adding versioning information to the JSON response.
parent
5f6796fb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/ccgapp.py
+16
-2
16 additions, 2 deletions
app/ccgapp.py
app/wccg.py
+0
-1
0 additions, 1 deletion
app/wccg.py
with
16 additions
and
3 deletions
app/ccgapp.py
+
16
−
2
View file @
cf7a5d39
import
json
import
uuid
from
flask
import
Flask
,
render_template
,
request
,
redirect
...
...
@@ -22,12 +23,25 @@ def is_non_gui_agent(ua_string):
return
any
(
ua
in
ua_string
for
ua
in
uas
)
def
create_response
(
sentence
):
content
=
wccg
.
parse
(
sentence
)
response
=
{
'
version
'
:
'
1.0.0
'
,
'
application
'
:
'
web-openccg
'
,
'
uuid
'
:
str
(
uuid
.
uuid4
())
}
response
.
update
(
content
)
return
response
@app.route
(
'
/gui
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
def
gui
():
"""
Presents a simple input form to a browser user.
"""
sentence
=
request
.
form
.
get
(
'
sentence
'
)
response
=
wccg
.
par
se
(
sentence
)
response
=
create_respon
se
(
sentence
)
response
=
json
.
dumps
(
response
,
indent
=
4
)
return
render_template
(
'
form.html
'
,
sentence
=
sentence
,
response
=
response
)
...
...
@@ -59,7 +73,7 @@ def index():
# The first key could be send e.g. by
# curl --data "This is the sentence." 127.0.0.1:5000
sentence
=
request
.
form
.
get
(
key
)
or
key
response
=
wccg
.
par
se
(
sentence
)
response
=
create_respon
se
(
sentence
)
return
json
.
dumps
(
response
),
response
[
'
http_status
'
]
return
redirect
(
'
/gui
'
,
code
=
307
)
...
...
This diff is collapsed.
Click to expand it.
app/wccg.py
+
0
−
1
View file @
cf7a5d39
...
...
@@ -92,6 +92,5 @@ def _as_dict(response):
parses
[
key
]
=
'
'
.
join
(
parse
)
return
dict
(
sentence
=
sentence
[
1
:
-
1
],
number
=
num_parses
,
parses
=
parses
,
http_status
=
200
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment