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
1010b272
Commit
1010b272
authored
Aug 26, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LANGDETECT set to TRUE
parent
65b8f9b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
4 deletions
+26
-4
constants.py
gargantext/constants.py
+1
-1
languages.py
gargantext/util/languages.py
+11
-0
timeit_damnit.py
gargantext/util/timeit_damnit.py
+10
-0
parsing.py
gargantext/util/toolchain/parsing.py
+4
-3
No files found.
gargantext/constants.py
View file @
1010b272
...
...
@@ -313,7 +313,7 @@ DEFAULT_INDEX_SUBGRAMS = False # False <=> traditional
# at indexing after extraction)
# TAGGING options -----------------------------------------
#activate lang detection?
DETECT_LANG
=
Fals
e
DETECT_LANG
=
Tru
e
# Defaults INDEXED Fields for ngrams extraction
# put longest field first in order to make detection language more efficient
DEFAULT_INDEX_FIELDS
=
(
'abstract'
,
'title'
)
...
...
gargantext/util/languages.py
View file @
1010b272
from
gargantext.constants
import
*
from
langdetect
import
detect
,
DetectorFactory
import
time
def
timing
(
f
):
def
wrap
(
*
args
):
time1
=
time
.
time
()
ret
=
f
(
*
args
)
time2
=
time
.
time
()
print
(
'function took
%0.3
f ms'
%
((
time2
-
time1
)
*
1000.0
))
return
ret
return
wrap
...
...
@@ -28,6 +38,7 @@ class Languages(dict):
languages
=
Languages
()
@
timing
def
detect_lang
(
text
):
DetectorFactory
.
seed
=
0
return
languages
[
detect
(
text
)]
.
iso2
...
...
gargantext/util/timeit_damnit.py
0 → 100644
View file @
1010b272
import
time
def
timing
(
f
):
def
wrap
(
*
args
):
time1
=
time
.
time
()
ret
=
f
(
*
args
)
time2
=
time
.
time
()
print
(
'
%
s function took
%0.3
f ms'
%
(
f
.
__name__
,
(
time2
-
time1
)
*
1000.0
))
return
ret
return
wrap
gargantext/util/toolchain/parsing.py
View file @
1010b272
...
...
@@ -5,7 +5,8 @@ from gargantext.constants import *
from
collections
import
defaultdict
,
Counter
from
re
import
sub
from
gargantext.util.languages
import
languages
,
detect_lang
import
time
def
add_lang
(
hyperdata
,
observed_languages
,
skipped_languages
):
...
...
@@ -54,12 +55,11 @@ def add_lang(hyperdata, observed_languages, skipped_languages):
else
:
print
(
"
DETECT LANG:"
,
DETECT_LANG
)
print
(
"
[WARNING] no language_* found in document [parsing.py]"
)
if
DETECT_LANG
is
False
:
skipped_languages
.
append
(
"__unknown__"
)
return
observed_languages
,
skipped_languages
print
(
"[WARNING] no language_* found in document [parsing.py]"
)
#no language have been indexed
#detectlang by joining on the DEFAULT_INDEX_FIELDS
text_fields2
=
list
(
set
(
DEFAULT_INDEX_FIELDS
)
&
set
(
hyperdata
.
keys
()))
...
...
@@ -84,6 +84,7 @@ def add_lang(hyperdata, observed_languages, skipped_languages):
def
parse
(
corpus
):
try
:
print
(
"PARSING"
)
print
(
"DETECT_LANG?"
,
DETECT_LANG
)
corpus
.
status
(
'Docs'
,
progress
=
0
)
#1 corpus => 1 or multi resources.path (for crawlers)
resources
=
corpus
.
resources
()
...
...
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