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
11fadebb
Commit
11fadebb
authored
Aug 26, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TAGGER .extract(text)
parent
9ee3d71d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
9 deletions
+22
-9
constants.py
gargantext/constants.py
+5
-5
NltkTagger.py
gargantext/util/taggers/NltkTagger.py
+13
-1
TreeTagger.py
gargantext/util/taggers/TreeTagger.py
+1
-0
TurboTagger.py
gargantext/util/taggers/TurboTagger.py
+2
-1
_Tagger.py
gargantext/util/taggers/_Tagger.py
+1
-2
No files found.
gargantext/constants.py
View file @
11fadebb
...
...
@@ -148,7 +148,7 @@ RESOURCETYPES = [
'name'
:
'Europresse'
,
'format'
:
'Europresse'
,
'parser'
:
"EuropresseParser"
,
'file_formats'
:[
"zip"
],
'file_formats'
:[
"zip"
,
"txt"
],
'crawler'
:
None
,
'default_languages'
:
[
'en'
,
'fr'
],
},
...
...
@@ -156,7 +156,7 @@ RESOURCETYPES = [
'name'
:
'Jstor [RIS]'
,
'format'
:
'RIS'
,
'parser'
:
"RISParser"
,
'file_formats'
:[
"zip"
],
'file_formats'
:[
"zip"
,
"txt"
],
'crawler'
:
None
,
'default_languages'
:
[
'en'
],
},
...
...
@@ -172,7 +172,7 @@ RESOURCETYPES = [
'name'
:
'Scopus [RIS]'
,
'format'
:
'RIS'
,
'parser'
:
"RISParser"
,
'file_formats'
:[
"zip"
],
'file_formats'
:[
"zip"
,
"txt"
],
'crawler'
:
None
,
'default_languages'
:
[
'en'
],
},
...
...
@@ -180,7 +180,7 @@ RESOURCETYPES = [
'name'
:
'Web of Science [ISI]'
,
'format'
:
'ISI'
,
'parser'
:
"ISIParser"
,
'file_formats'
:[
"zip"
],
'file_formats'
:[
"zip"
,
"txt"
],
#'crawler': "ISICrawler",
'crawler'
:
None
,
'default_languages'
:
[
'en'
],
...
...
@@ -205,7 +205,7 @@ RESOURCETYPES = [
'name'
:
'ISTex'
,
'format'
:
'json'
,
'parser'
:
"ISTexParser"
,
'file_formats'
:[
"zip"
],
'file_formats'
:[
"zip"
,
"txt"
],
'crawler'
:
None
,
'default_languages'
:
[
'en'
,
'fr'
],
},
...
...
gargantext/util/taggers/NltkTagger.py
View file @
11fadebb
...
...
@@ -10,8 +10,20 @@ class NltkTagger(Tagger):
self
.
tagr
=
PerceptronTagger
()
super
(
self
.
__class__
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
#
~
def __start__(self):
#def __start__(self):
#~ self.tagr = PerceptronTagger()
def
tag_tokens
(
self
,
tokens
,
single
=
True
):
return
self
.
tagr
.
tag
(
tokens
)
def
extract
(
self
,
text
,
rule
=
RULE_JJNN
,
label
=
'NP'
,
max_n_words
=
DEFAULT_MAX_NGRAM_LEN
):
self
.
text
=
self
.
clean_text
(
text
)
grammar
=
nltk
.
RegexpParser
(
label
+
': '
+
rule
)
tagged_tokens
=
list
(
self
.
tag_text
(
self
.
text
))
if
len
(
tagged_tokens
):
grammar_parsed
=
grammar
.
parse
(
tagged_tokens
)
for
subtree
in
grammar_parsed
.
subtrees
():
if
subtree
.
label
()
==
label
:
if
len
(
subtree
)
<
max_n_words
:
yield
subtree
.
leaves
()
# ex: [('wild', 'JJ'), ('pollinators', 'NNS')]
gargantext/util/taggers/TreeTagger.py
View file @
11fadebb
...
...
@@ -74,6 +74,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()
# self.extract(self.text)
def
stop
(
self
):
# terminates the 'treetagger' process
...
...
gargantext/util/taggers/TurboTagger.py
View file @
11fadebb
...
...
@@ -6,12 +6,13 @@ class TurboTagger:
def
start
(
self
):
self
.
_nlpclient
=
NLPClient
()
#self.extract(self.text)
def
stop
(
self
):
if
hasattr
(
self
,
'_nlpclient'
):
del
self
.
_nlpclient
def
tag_tex
t
(
self
,
text
):
def
extrac
t
(
self
,
text
):
if
not
hasattr
(
self
,
'_nlpclient'
):
self
.
_nlpclient
=
NLPClient
()
try
:
...
...
gargantext/util/taggers/_Tagger.py
View file @
11fadebb
...
...
@@ -19,8 +19,7 @@ class Tagger:
| [][.,;"'?!():-_`] # these are separate tokens
'''
,
re
.
UNICODE
|
re
.
MULTILINE
|
re
.
DOTALL
)
self
.
buffer
=
[]
#self.start()
self
.
start
()
def
clean_text
(
self
,
text
):
...
...
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