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
60b36dcc
Commit
60b36dcc
authored
Oct 23, 2014
by
Mathieu Rodic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] Ngrams extractors - Implemented a cache for the extractors
parent
f6122f1c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
4 deletions
+38
-4
EnglishNgramsExtractor.py
parsing/NgramsExtractors/EnglishNgramsExtractor.py
+1
-0
__init__.py
parsing/NgramsExtractors/__init__.py
+35
-3
TreeTagger.py
parsing/Taggers/TreeTagger.py
+1
-1
__init__.py
parsing/Taggers/__init__.py
+1
-0
No files found.
parsing/NgramsExtractors/EnglishNgramsExtractor.py
View file @
60b36dcc
...
...
@@ -7,3 +7,4 @@ class EnglishNgramsExtractor(NgramsExtractor):
def
start
(
self
):
self
.
tagger
=
NltkTagger
()
\ No newline at end of file
parsing/NgramsExtractors/__init__.py
View file @
60b36dcc
#from NgramsExtractors.FrenchNgramsExtractor import FrenchNgramsExtractor
#from NgramsExtractors.EnglishNgramsExtractor import EnglishNgramsExtractor
from
parsing.NgramsExtractors.FrenchNgramsExtractor
import
FrenchNgramsExtractor
from
parsing.NgramsExtractors.EnglishNgramsExtractor
import
EnglishNgramsExtractor
from
parsing.NgramsExtractors.NgramsExtractor
import
NgramsExtractor
import
collections
class
NgramsExtractorsCache
(
collections
.
defaultdict
):
"""This allows the fast retrieval of ngram ids
from a cache instead of calling the database every time
"""
def
__missing__
(
self
,
key
):
# format the language
if
isinstance
(
key
,
str
):
language
=
key
.
strip
()
.
lower
()
else
:
language
=
key
.
iso3
# find the proper extractor
if
language
in
[
"en"
,
"eng"
,
"english"
]:
Extractor
=
EnglishNgramsExtractor
elif
language
in
[
"fr"
,
"fra"
,
"fre"
,
"french"
]:
Extractor
=
FrenchNgramsExtractor
else
:
Extractor
=
NgramsExtractor
# try to see if already instanciated, otherwise do it
found
=
False
for
extractor
in
self
.
values
():
if
type
(
extractor
)
==
Extractor
:
self
[
key
]
=
extractor
found
=
True
break
if
not
found
:
self
[
key
]
=
Extractor
()
# return the proper extractor
return
self
[
key
]
parsing/Taggers/TreeTagger.py
View file @
60b36dcc
...
...
@@ -46,7 +46,7 @@ Shall be used for french texts.
"""
class
TreeTagger
(
Tagger
):
def
start
(
self
,
treeTaggerPath
=
"./Taggers/treetagger"
):
def
start
(
self
,
treeTaggerPath
=
"./
parsing/
Taggers/treetagger"
):
binaryFile
=
"
%
s/bin/tree-tagger"
%
treeTaggerPath
tagcmdlist
=
[
binaryFile
,
...
...
parsing/Taggers/__init__.py
View file @
60b36dcc
from
parsing.Taggers.Tagger
import
Tagger
from
parsing.Taggers.NltkTagger
import
NltkTagger
from
parsing.Taggers.TreeTagger
import
TreeTagger
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