Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
texta
texta-mlp-python
Commits
ba61335e
Commit
ba61335e
authored
May 19, 2021
by
Marko Kollo
😄
Browse files
Hide lemmas value when it's None, remove None value when evaluating for duplicates.
parent
99e2e636
Pipeline
#5584
passed with stage
in 29 minutes and 23 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
texta_mlp/document.py
View file @
ba61335e
...
...
@@ -98,9 +98,20 @@ class Document:
self
.
add_fact
(
fact
)
@
staticmethod
def
handle_null_values_in_facts
(
facts
:
List
[
dict
]):
container
=
[]
if
facts
:
for
fact
in
facts
:
new_fact
=
{
key
:
value
for
key
,
value
in
fact
.
items
()
if
value
is
not
None
}
container
.
append
(
new_fact
)
return
container
@
staticmethod
def
remove_duplicate_facts
(
facts
:
List
[
dict
]):
if
facts
:
facts
=
Document
.
handle_null_values_in_facts
(
facts
)
set_of_jsons
=
{
json
.
dumps
(
fact
,
sort_keys
=
True
,
ensure_ascii
=
False
)
for
fact
in
facts
}
without_duplicates
=
[
json
.
loads
(
unique_fact
)
for
unique_fact
in
set_of_jsons
]
return
without_duplicates
...
...
texta_mlp/fact.py
View file @
ba61335e
...
...
@@ -26,10 +26,12 @@ class Fact:
def
to_json
(
self
):
return
{
container
=
{
"str_val"
:
self
.
fact_value
,
"spans"
:
json
.
dumps
(
self
.
spans
),
"fact"
:
self
.
fact_type
,
"doc_path"
:
self
.
doc_path
,
"lemma"
:
self
.
fact_lemma
}
if
self
.
fact_lemma
:
container
[
"lemma"
]
=
self
.
fact_lemma
return
container
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