Commit 37716c5a authored by Łukasz Kopociński's avatar Łukasz Kopociński

Fix flake8 issues

parent 748af830
from .corpus import Document, DocSentence, DocToken, DocRelation
from .utils import from_index_documents_gen, relations_files_paths, \
documents_gen
__all__ = [
'Document',
'DocSentence',
'DocToken',
'DocRelation',
'from_index_documents_gen',
'relations_files_paths',
'documents_gen'
]
......@@ -117,22 +117,13 @@ class RelationsGenerator:
def _are_in_relation(
self, member_from: Member, member_to: Member, relations: List
):
return member_from and member_to and (
Relation(
self._document.id,
member_from,
member_to
) in relations
or
Relation(
self._document.id,
member_to,
member_from
) in relations
)
) -> bool:
if not (member_from and member_to):
return False
else:
rel_from_to = Relation(self._document.id, member_from, member_to)
rel_to_from = Relation(self._document.id, member_to, member_from)
return rel_from_to in relations or rel_to_from in relations
class RelationsLoader:
......
......@@ -11,7 +11,7 @@ from torch.utils.data import DataLoader
from semrel.model import runs
from semrel.model.scripts import RelNet
from semrel.model.scripts.utils import parse_config, get_device, \
from semrel.model.scripts.utils.utils import parse_config, get_device, \
is_better_loss, ignored
from semrel.model.scripts.utils.data_loader import get_loaders
from semrel.model.scripts.utils.metrics import Metrics
......
......@@ -56,10 +56,8 @@ class DatasetGenerator:
return {
index
for index in indices
if (
self.dataset_keys[index][4] in channels
or self.dataset_keys[index][9] in channels
)
if (self.dataset_keys[index][4] in channels
or self.dataset_keys[index][9] in channels)
}
def _split(self, indices) -> Tuple[List, List, List]:
......@@ -257,9 +255,7 @@ def get_loaders(
)
return Loaders(
train=train_loader,
valid=valid_loader,
test=test_loader,
vector_size=dataset.vector_size
)
return Loaders(train=train_loader,
valid=valid_loader,
test=test_loader,
vector_size=dataset.vector_size)
......@@ -58,8 +58,10 @@ def map_relations(
for relation in diff_context_relations
]
spert_relations = spert_same_context_relations + spert_diff_context_relations
spert_keys = spert_same_context_relations_keys + spert_diff_context_relations_keys
spert_relations = (spert_same_context_relations
+ spert_diff_context_relations)
spert_keys = (spert_same_context_relations_keys
+ spert_diff_context_relations_keys)
return generate_spert_jsons(spert_relations, spert_keys)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment