Download recognizers/base.py from ZurichNLP/unsupervised-semantic-diff: direct link, hf CLI and curl.
- Browser
- Download file 879 Bytes
-
https://huggingface.co/spaces/ZurichNLP/unsupervised-semantic-diff/resolve/refs%2Fpr%2F5/recognizers/base.py
- Command line
-
hf download hf://spaces/ZurichNLP/unsupervised-semantic-diff@refs/pr/5/recognizers/base.py
-
curl -L -o base.py https://huggingface.co/spaces/ZurichNLP/unsupervised-semantic-diff/resolve/refs%2Fpr%2F5/recognizers/base.py
879 Bytes
| """ | |
| Source: https://github.com/ZurichNLP/recognizing-semantic-differences | |
| MIT License | |
| Copyright (c) 2023 University of Zurich | |
| """ | |
| from typing import List | |
| from tqdm import tqdm | |
| from recognizers.utils import DifferenceSample | |
| class DifferenceRecognizer: | |
| def __str__(self): | |
| raise NotImplemented | |
| def predict(self, | |
| a: str, | |
| b: str, | |
| **kwargs, | |
| ) -> DifferenceSample: | |
| raise NotImplemented | |
| def predict_all(self, | |
| a: List[str], | |
| b: List[str], | |
| **kwargs, | |
| ) -> List[DifferenceSample]: | |
| assert len(a) == len(b) | |
| predictions = [] | |
| for i in tqdm(list(range(len(a)))): | |
| prediction = self.predict(a[i], b[i], **kwargs) | |
| predictions.append(prediction) | |
| return predictions | |