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
1bc502cf
Commit
1bc502cf
authored
Aug 26, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PATCH
parent
97f70d54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+1
-1
parsing.py
gargantext/util/toolchain/parsing.py
+8
-3
No files found.
gargantext/util/toolchain/ngrams_extraction.py
View file @
1bc502cf
...
...
@@ -58,7 +58,7 @@ def extract_ngrams(corpus, keys=DEFAULT_INDEX_FIELDS, do_subngrams = DEFAULT_IND
# for lang, tagger in tagger_bots.items():
for
documents_count
,
document
in
enumerate
(
corpus
.
children
(
'DOCUMENT'
)):
if
doc
.
id
not
in
corpus
.
hyperdata
[
"skipped_docs"
]:
if
doc
ument
.
id
not
in
corpus
.
hyperdata
[
"skipped_docs"
]:
language_iso2
=
document
.
hyperdata
.
get
(
'language_iso2'
)
if
language_iso2
not
in
supported_taggers_lang
:
#print("ERROR NO language_iso2")
...
...
gargantext/util/toolchain/parsing.py
View file @
1bc502cf
...
...
@@ -47,8 +47,11 @@ def add_lang(hyperdata, observed_languages, skipped_languages):
print
(
"[WARNING] no language_* found in document [parsing.py]"
)
#no language have been indexed
#detectlang by joining on DEFAULT_INDEX_FIELDS
#text_fields = [k for k in DEFAULT_INDEX_FIELDS if k in hyperdata.keys()]
text_fields2
=
list
(
set
(
DEFAULT_INDEX_FIELDS
)
&
set
(
hyperdata
.
keys
()))
print
(
len
(
text_fields2
))
text
=
" "
.
join
([
getattr
(
hyperdata
,
k
)
for
k
in
DEFAULT_INDEX_FIELDS
])
text
=
" "
.
join
([
hyperdata
[
k
]
for
k
in
text_fields2
])
if
len
(
text
)
<
10
:
hyperdata
[
"error"
]
=
"Error: no TEXT fields to index"
skipped_languages
.
append
(
"__unknown__"
)
...
...
@@ -146,11 +149,13 @@ def parse(corpus):
print
(
observed_langs
)
print
(
"#LANGUAGES UNKNOWN"
)
print
(
skipped_langs
)
corpus
.
language_id
=
sorted
(
observed_langs
.
items
(),
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)[
0
][
0
]
print
(
"#MAIN language of the CORPUS"
,
corpus
.
language_id
)
corpus
.
hyperdata
[
"language_id"
]
=
sorted
(
observed_langs
.
items
(),
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)[
0
][
0
]
print
(
"#MAIN language of the CORPUS"
,
corpus
.
hyperdata
[
"language_id"
])
corpus
.
hyperdata
[
"languages"
]
=
dict
(
observed_langs
)
corpus
.
hyperdata
[
"languages"
][
"__unknown__"
]
=
list
(
skipped_langs
.
keys
())
print
(
"OBSERVED_LANGUAGES"
,
corpus
.
hyperdata
[
"languages"
])
corpus
.
save_hyperdata
()
#TODO: assign main lang of the corpus to unsupported languages docs
...
...
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