From 2a00de9f05103c5d742511711dcce8d7b41720ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20W=C4=85troba?= <markowanga@gmail.com> Date: Tue, 15 Jun 2021 08:00:00 +0200 Subject: [PATCH] Fix editing --- .../core/wer/wer_embedding_calculator.py | 5 ++- .../metrics_calculator.cpython-38.pyc | Bin 1615 -> 0 bytes .../integration/metrics_calculator.py | 34 ------------------ sziszapangma/integration/path_filter.py | 4 ++- .../repository/mongo_experiment_repository.py | 2 +- .../integration/task/gold_transcript_task.py | 1 - 6 files changed, 8 insertions(+), 38 deletions(-) delete mode 100644 sziszapangma/integration/__pycache__/metrics_calculator.cpython-38.pyc delete mode 100644 sziszapangma/integration/metrics_calculator.py diff --git a/sziszapangma/core/wer/wer_embedding_calculator.py b/sziszapangma/core/wer/wer_embedding_calculator.py index 30dc82a..5f371b7 100644 --- a/sziszapangma/core/wer/wer_embedding_calculator.py +++ b/sziszapangma/core/wer/wer_embedding_calculator.py @@ -19,7 +19,10 @@ class WerEmbeddingCalculator(WerCalculator): self._distance_calculator = CosineDistanceCalculator( embedding_transformer) - def _calculate_distance_for_word_step(self, step_words: StepWords) -> float: + def _calculate_distance_for_word_step( + self, + step_words: StepWords + ) -> float: return self._distance_calculator.calculate_distance_for_words( step_words.reference_word, step_words.hypothesis_word diff --git a/sziszapangma/integration/__pycache__/metrics_calculator.cpython-38.pyc b/sziszapangma/integration/__pycache__/metrics_calculator.cpython-38.pyc deleted file mode 100644 index 64abcc4563ec492321106b4c30b36abb903f4342..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1615 zcma)6OK%%D5GJ_~t=F<0w@KTyJqRd}U@ubd6^s;eQWQvBAgW<tfq-R}l)UXe6p}(< zK{?si9&+!YIp&x2+$*m=^)Cc%)0x%7uH{1saF)x*@cX`*;qlH+OrSmb{kI?9dxZRf zKUW*fkq6MtJus4_L{iBLTC$XtUg}Zu4UwMoFNpNdS?bGRNRsf~XHP_4buv+8(?Zx< zcj{56R95Gi>HZ0hNWz@|I5*b$hk0f*oVwZq_;~=`XfTST6mDk6aChn{Uj>r&m$#;& zYN<$VsaS1~*j;j$z+ViuErVY?8Oqj$e@@e#8~3bFHG3nub>XMGG6n|QZvV*w?qJP9 zQ^4Xr;wx5)XN52(&-hEFGX{&RhGXml=mzDT(>dXw9(bll3DqIYp#nw~qx8;=4&M?T z!LE1DddEg-(<_C}^6I6qx_&Nthsyk9>q+nAc=&zK%yKgm6H$#z@!y}kvTCe_&FiYS zlz$Ds*4@dOi#X4#+;WaEO+$jtKHcEnU2RJ|w>Pc}$*mTZ$#g!kE*3^}t<1ErF4W3S zb+sXf5AGW|Ixw(J5?zovIV9&4(ucvAHe>&11|kJV8H&AX2n!typ_|)a#&Gmm`xTv2 z3lV?KUiia>TnSABe)8SZ!?(<_?w5|`wvlmRw&19X`vv4(R+p25578ew4k28#uWn$i zrxiwbEgA@Ey8WVtkeLG*tUPVN#j<JO-hx2`H$u2qpe`Wo!tynQdLQPH<r-ST(k-n< zN~<bUX?%J%sqLvUxdFPjO<qn4$i-!zD#V*Gy^W6Bo8H|WeiNx3yblwO1dO(6`=8nU z|0zd?R96kfycX(n^2(c&AF2M_vR^%@1ono_J?r<$+{1d9-5ac+cSKRFo{7!~UJWU% z=oo<nyGh`D32#MHJQ^Pe{Q;P?%?FRa9uB`9@RNs66JNJ*Wz9ZqE%W}G$Zr2qu;q@A z;h@2IkT9en^(iCledNu)*c4*p>`}6ZrBsPhaqeQy%UVt$D%`a>e=!xsa;3$&tTUMQ zpVxKa_Ba<+RokXQ4d)uG(6tRtWB}{5mKx>NsHyXe)y@;unF~fm4KD%m*O)0+$YBgM zCVC?g%49wP6H}i>Eb<uJ1#ax`-EI8Fe>J;~l0f4o7uvH)UX3sBT<F~RyfjT2Mg0ZE N11!`gQ+;~N`xiBNhTi}H diff --git a/sziszapangma/integration/metrics_calculator.py b/sziszapangma/integration/metrics_calculator.py deleted file mode 100644 index 0d145c0..0000000 --- a/sziszapangma/integration/metrics_calculator.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Main calculator of metrics.""" -from typing import List, Dict - - -class MetricsCalculator: - """Main calculator of metrics.""" - - _calculate_classic_wer: bool - - def __init__(self, calculate_classic_wer): - self._calculate_classic_wer = calculate_classic_wer - - @staticmethod - def _run_wer_calculations( - gold_transcript: List[Dict[str, any]], - asr_result: List[str] - ) -> float: - return simple_calculate_wer( - reference=[it[_WORD] for it in gold_transcript], - hypothesis=[it for it in asr_result], - ) - - def calculate_metrics( - self, - gold_transcript: List[Dict[str, any]], - asr_result: List[str] - ) -> Dict[str, any]: - """Calculate all metrics for data sample.""" - metrics = dict() - if self._calculate_classic_wer: - metrics[_CLASSIC_WER] = MetricsCalculator._run_wer_calculations( - gold_transcript, asr_result) - # TODO: put additional metrics here - return metrics diff --git a/sziszapangma/integration/path_filter.py b/sziszapangma/integration/path_filter.py index aa9db3a..1ac6eb4 100644 --- a/sziszapangma/integration/path_filter.py +++ b/sziszapangma/integration/path_filter.py @@ -38,9 +38,11 @@ class ExtensionPathFilter(PathFilter): """ Implementation of searching files with extension. """ + path_generator = Path(self._root_directory).glob( + f'**/*.{self._extension}') all_files = [ str(it) - for it in Path(self._root_directory).glob(f'**/*.{self._extension}') + for it in path_generator ] return all_files \ if self._files_limit is None \ diff --git a/sziszapangma/integration/repository/mongo_experiment_repository.py b/sziszapangma/integration/repository/mongo_experiment_repository.py index 73f3f6f..19c11aa 100644 --- a/sziszapangma/integration/repository/mongo_experiment_repository.py +++ b/sziszapangma/integration/repository/mongo_experiment_repository.py @@ -1,4 +1,4 @@ -from typing import Optional, List, Set +from typing import Optional, Set from pymongo import MongoClient from pymongo.database import Database diff --git a/sziszapangma/integration/task/gold_transcript_task.py b/sziszapangma/integration/task/gold_transcript_task.py index 291eb80..0b407b4 100644 --- a/sziszapangma/integration/task/gold_transcript_task.py +++ b/sziszapangma/integration/task/gold_transcript_task.py @@ -1,6 +1,5 @@ from sziszapangma.integration.gold_transcript_processor import \ GoldTranscriptProcessor -from sziszapangma.integration.record_path_provider import RecordPathProvider from sziszapangma.integration.repository.experiment_repository \ import ExperimentRepository from sziszapangma.integration.task.processing_task import ProcessingTask -- GitLab