Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
Андрей Козлюк committed Mar 27, 2022
1 parent f23d7e2 commit b6f4857
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
1 change: 0 additions & 1 deletion para_tri_dataset/paraphrase_dataset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Phrase(AbstractDataclass):


class ParaphraseDataset(abc.ABC):

@classmethod
@abc.abstractmethod
def from_config(cls, cfg: Config) -> "ParaphraseDataset":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class ParaPhraserPlusPhrase(Phrase):
text: str


def parse_json_dataset(dataset: SerializedDatasetType)\
-> Generator[Tuple[ParaPhraserPlusPhrase, Tuple[int, ...]], None, None]:
def parse_json_dataset(
dataset: SerializedDatasetType,
) -> Generator[Tuple[ParaPhraserPlusPhrase, Tuple[int, ...]], None, None]:

offset = 0
for serialized_record in dataset.values():
Expand Down Expand Up @@ -111,7 +112,7 @@ def get_paraphrases(self, phrase: ParaPhraserPlusPhrase) -> Tuple[ParaPhraserPlu
try:
paraphrases_ids = self.phrases_relations[phrase.id]
except IndexError as err:
raise ValueError(f'not fount phrase by id {phrase.id}') from err
raise ValueError(f"not fount phrase by id {phrase.id}") from err

return tuple(self.get_phrase_by_id(p_id) for p_id in paraphrases_ids)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def dataset(phrase_a, phrase_b) -> ParaPhraserPlusFileDataset:
phrase_a,
phrase_b,
),
((1,), (0,),)
(
(1,),
(0,),
),
)


Expand Down Expand Up @@ -75,11 +78,15 @@ def test_iterate_phrases(dataset: ParaPhraserPlusFileDataset, phrase_a, phrase_b
assert next(dataset.iterate_phrases(offset=1)) == phrase_b

phrases_id = tuple(dataset.iterate_phrases_id())
assert phrases_id == (0, 1,)
assert phrases_id == (
0,
1,
)


def test_get_paraphrases(dataset: ParaPhraserPlusFileDataset, phrase_a: ParaPhraserPlusPhrase,
phrase_b: ParaPhraserPlusPhrase):
def test_get_paraphrases(
dataset: ParaPhraserPlusFileDataset, phrase_a: ParaPhraserPlusPhrase, phrase_b: ParaPhraserPlusPhrase
):

paraphrases_a = dataset.get_paraphrases(phrase_a)
assert len(paraphrases_a) == 1
Expand All @@ -98,8 +105,9 @@ def test_get_paraphrases(dataset: ParaPhraserPlusFileDataset, phrase_a: ParaPhra
assert paraphrases_id_b[0] == phrase_a.id


def test_get_phrase_by_idx(dataset: ParaPhraserPlusFileDataset, phrase_a: ParaPhraserPlusPhrase,
phrase_b: ParaPhraserPlusPhrase):
def test_get_phrase_by_idx(
dataset: ParaPhraserPlusFileDataset, phrase_a: ParaPhraserPlusPhrase, phrase_b: ParaPhraserPlusPhrase
):

assert phrase_a == dataset.get_phrase_by_id(0)
assert phrase_b == dataset.get_phrase_by_id(1)
Expand Down
1 change: 0 additions & 1 deletion para_tri_dataset/phrase_vector_model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class PhraseNumpyVector(PhraseVector):


class PhraseVectorModel(abc.ABC):

@classmethod
@abc.abstractmethod
def from_config(cls, cfg: Config) -> "PhraseVectorModel":
Expand Down

0 comments on commit b6f4857

Please sign in to comment.