Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
88ed67db
Commit
88ed67db
authored
May 22, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'testing' into prod-dev
parents
0fed5bf9
7b02b775
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
TreeTagger.py
parsing/Taggers/TreeTagger.py
+9
-9
No files found.
parsing/Taggers/TreeTagger.py
View file @
88ed67db
...
...
@@ -10,7 +10,7 @@ import time
class
identity_dict
(
dict
):
def
__missing__
(
self
,
key
):
return
key
_tag_replacements
=
identity_dict
({
"NOM"
:
"NN"
,
"NAM"
:
"NN"
,
...
...
@@ -45,8 +45,8 @@ def _readOutput(output, buffer):
Shall be used for french texts.
"""
class
TreeTagger
(
Tagger
):
def
start
(
self
,
treeTaggerPath
=
"./parsing/Taggers/treetagger"
):
def
start
(
self
,
treeTaggerPath
=
"./parsing/Taggers/
lib/
treetagger"
):
binaryFile
=
"
%
s/bin/tree-tagger"
%
treeTaggerPath
tagcmdlist
=
[
binaryFile
,
...
...
@@ -67,7 +67,7 @@ class TreeTagger(Tagger):
self
.
_input
,
self
.
_output
=
self
.
_popen
.
stdin
,
self
.
_popen
.
stdout
# self._thread = threading.Thread(target=_readOutput, args=(self._output, self.buffer, )).start()
# self.buffer = OutputBuffer()
def
stop
(
self
):
# terminates the 'treetagger' process
try
:
...
...
@@ -75,20 +75,20 @@ class TreeTagger(Tagger):
self
.
_popen
.
terminate
()
except
:
pass
def
tagging_start
(
self
):
self
.
buffer
=
[]
self
.
_thread
=
threading
.
Thread
(
target
=
_readOutput
,
args
=
(
self
.
_output
,
self
.
buffer
,
))
self
.
_thread
.
start
()
self
.
_input
.
write
(
b
"<block>
\n
"
)
def
tagging_end
(
self
):
self
.
_input
.
write
(
b
"<block/>
\n
"
)
# sends some dummy tokens, then wait for the text to be treated
self
.
tag_tokens
(
"Les sanglots longs des violons de l ' automne bercent mon coeur d ' une langueur monotone ."
.
split
(),
False
)
self
.
_thread
.
join
()
def
tag_tokens
(
self
,
tokens
,
single
=
True
):
if
single
:
self
.
tagging_start
()
...
...
@@ -97,7 +97,7 @@ class TreeTagger(Tagger):
if
single
:
self
.
tagging_end
()
return
self
.
buffer
def
tag_text
(
self
,
text
):
self
.
tagging_start
()
for
line
in
text
.
split
(
'
\n
'
):
...
...
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