Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,12 +83,25 @@ aspect_aliases = {
|
|
| 83 |
"value": "cena", "experience": "doświadczenie", "recommendation": "ogólna ocena",
|
| 84 |
"children": "dzieci", "family": "rodzina", "pet": "zwierzęta"
|
| 85 |
}
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
-
def translate_en_to_pl(texts):
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
|
| 94 |
def extract_aspects(text_en: str):
|
|
|
|
| 83 |
"value": "cena", "experience": "doświadczenie", "recommendation": "ogólna ocena",
|
| 84 |
"children": "dzieci", "family": "rodzina", "pet": "zwierzęta"
|
| 85 |
}
|
| 86 |
+
# ───────────────────── tłumaczenia ──────────────────────
|
| 87 |
+
def translate_pl_to_en(texts: list[str]) -> list[str]:
|
| 88 |
+
inputs = pl_to_en_tok(texts,
|
| 89 |
+
return_tensors="pt",
|
| 90 |
+
padding=True,
|
| 91 |
+
truncation=True).to(device)
|
| 92 |
+
with torch.no_grad():
|
| 93 |
+
generated = pl_to_en_mod.generate(**inputs)
|
| 94 |
+
return pl_to_en_tok.batch_decode(generated, skip_special_tokens=True)
|
| 95 |
|
| 96 |
|
| 97 |
+
def translate_en_to_pl(texts: list[str]) -> list[str]:
|
| 98 |
+
inputs = en_to_pl_tok(texts,
|
| 99 |
+
return_tensors="pt",
|
| 100 |
+
padding=True,
|
| 101 |
+
truncation=True).to(device)
|
| 102 |
+
with torch.no_grad():
|
| 103 |
+
generated = en_to_pl_mod.generate(**inputs)
|
| 104 |
+
return en_to_pl_tok.batch_decode(generated, skip_special_tokens=True)
|
| 105 |
|
| 106 |
|
| 107 |
def extract_aspects(text_en: str):
|