Spaces:
Runtime error
Runtime error
DeDeckerThomas
commited on
Commit
·
55b038b
1
Parent(s):
860c19c
Fix last bugs
Browse files
pipelines/__pycache__/keyphrase_generation_pipeline.cpython-39.pyc
CHANGED
Binary files a/pipelines/__pycache__/keyphrase_generation_pipeline.cpython-39.pyc and b/pipelines/__pycache__/keyphrase_generation_pipeline.cpython-39.pyc differ
|
|
pipelines/keyphrase_generation_pipeline.py
CHANGED
@@ -3,6 +3,7 @@ from transformers import (
|
|
3 |
AutoModelForSeq2SeqLM,
|
4 |
AutoTokenizer,
|
5 |
)
|
|
|
6 |
|
7 |
|
8 |
class KeyphraseGenerationPipeline(Text2TextGenerationPipeline):
|
@@ -17,14 +18,13 @@ class KeyphraseGenerationPipeline(Text2TextGenerationPipeline):
|
|
17 |
|
18 |
def postprocess(self, model_outputs):
|
19 |
results = super().postprocess(model_outputs=model_outputs)
|
20 |
-
print(results)
|
21 |
return [
|
22 |
[
|
23 |
-
keyphrase.strip()
|
24 |
for keyphrase in result.get("generated_text").split(
|
25 |
self.keyphrase_sep_token
|
26 |
)
|
27 |
-
if keyphrase != ""
|
28 |
]
|
29 |
for result in results
|
30 |
][0]
|
|
|
3 |
AutoModelForSeq2SeqLM,
|
4 |
AutoTokenizer,
|
5 |
)
|
6 |
+
import string
|
7 |
|
8 |
|
9 |
class KeyphraseGenerationPipeline(Text2TextGenerationPipeline):
|
|
|
18 |
|
19 |
def postprocess(self, model_outputs):
|
20 |
results = super().postprocess(model_outputs=model_outputs)
|
|
|
21 |
return [
|
22 |
[
|
23 |
+
keyphrase.strip().translate(str.maketrans('', '', string.punctuation))
|
24 |
for keyphrase in result.get("generated_text").split(
|
25 |
self.keyphrase_sep_token
|
26 |
)
|
27 |
+
if keyphrase.translate(str.maketrans('', '', string.punctuation)) != ""
|
28 |
]
|
29 |
for result in results
|
30 |
][0]
|