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
7002c9e3
Commit
7002c9e3
authored
May 17, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix case when languages are recognized through iso3 but have no code in iso2
parent
912d76f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
3 deletions
+24
-3
_Parser.py
gargantext/util/parsers/_Parser.py
+19
-2
__init__.py
gargantext/util/toolchain/__init__.py
+4
-0
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+1
-1
No files found.
gargantext/util/parsers/_Parser.py
View file @
7002c9e3
...
@@ -126,10 +126,27 @@ class Parser:
...
@@ -126,10 +126,27 @@ class Parser:
break
break
except
KeyError
:
except
KeyError
:
language_keyerrors
[
key
]
=
language_symbol
language_keyerrors
[
key
]
=
language_symbol
# languages can find Language objects from any code iso2 or iso3
# --------------------------------------------------------------
# > languages['fr']
# <Language iso3="fra" iso2="fr" implemented="True" name="French">
# > languages['fra']
# <Language iso3="fra" iso2="fr" implemented="True" name="French">
if
language
is
not
None
:
if
language
is
not
None
:
hyperdata
[
'language_iso2'
]
=
language
.
iso2
hyperdata
[
'language_iso3'
]
=
language
.
iso3
hyperdata
[
'language_name'
]
=
language
.
name
hyperdata
[
'language_name'
]
=
language
.
name
hyperdata
[
'language_iso3'
]
=
language
.
iso3
if
(
language
.
iso2
is
not
None
):
# NB: language can be recognized through iso3 but have no iso2!!
# because there's *more* languages in iso3 codes (iso-639-3)
# exemple:
# > languages['dnj']
# <Language iso3="dnj" iso2="None" implemented="False" name="Dan">
# ----
hyperdata
[
'language_iso2'
]
=
language
.
iso2
else
:
# 'None' would become json 'null' ==> "__unknown__" more stable
hyperdata
[
'language_iso2'
]
=
"__unknown__"
elif
language_keyerrors
:
elif
language_keyerrors
:
print
(
'Unrecognized language:
%
s'
%
', '
.
join
(
print
(
'Unrecognized language:
%
s'
%
', '
.
join
(
'
%
s="
%
s"'
%
(
key
,
value
)
for
key
,
value
in
language_keyerrors
.
items
()
'
%
s="
%
s"'
%
(
key
,
value
)
for
key
,
value
in
language_keyerrors
.
items
()
...
...
gargantext/util/toolchain/__init__.py
View file @
7002c9e3
...
@@ -54,6 +54,10 @@ def parse_extract_indexhyperdata(corpus):
...
@@ -54,6 +54,10 @@ def parse_extract_indexhyperdata(corpus):
corpus
.
status
(
'Workflow'
,
progress
=
1
)
corpus
.
status
(
'Workflow'
,
progress
=
1
)
corpus
.
save_hyperdata
()
corpus
.
save_hyperdata
()
session
.
commit
()
session
.
commit
()
# FIXME: 'Workflow' will still be uncomplete when 'Index' and 'Lists' will
# get stacked into hyperdata['statuses'], but doing corpus.status()
# will return only the 1st uncomplete action (corpus.status() doesn't
# understand "subactions")
# apply actions
# apply actions
print
(
'CORPUS #
%
d'
%
(
corpus
.
id
))
print
(
'CORPUS #
%
d'
%
(
corpus
.
id
))
...
...
gargantext/util/toolchain/ngrams_extraction.py
View file @
7002c9e3
...
@@ -56,7 +56,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
...
@@ -56,7 +56,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
ngramsextractor
=
ngramsextractors
[
language_iso2
]
ngramsextractor
=
ngramsextractors
[
language_iso2
]
except
KeyError
:
except
KeyError
:
# skip document
# skip document
print
(
'Unsupported language: `
%
s`
'
%
(
language_iso2
,
))
print
(
'Unsupported language: `
%
s`
(doc #
%
i)'
%
(
language_iso2
,
document
.
id
))
# and remember that for later processes (eg stemming)
# and remember that for later processes (eg stemming)
document
.
hyperdata
[
'__skipped__'
]
=
'ngrams_extraction'
document
.
hyperdata
[
'__skipped__'
]
=
'ngrams_extraction'
document
.
save_hyperdata
()
document
.
save_hyperdata
()
...
...
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