Spaces:
Sleeping
Sleeping
Constantin Orasan
commited on
Commit
·
538dc0d
1
Parent(s):
c4dbf82
Updated the app
Browse files- app.py +18 -7
- bpe.model → bpe-ECB.model +0 -0
- bpe-EMEA.model +0 -0
app.py
CHANGED
|
@@ -3,15 +3,26 @@ import sentencepiece as spm
|
|
| 3 |
|
| 4 |
examples = [
|
| 5 |
"Hello, world!",
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"
|
| 9 |
|
| 10 |
|
| 11 |
def greet(sentence):
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
demo = gr.Interface(fn=greet, inputs="text", outputs="html",
|
|
@@ -20,4 +31,4 @@ demo = gr.Interface(fn=greet, inputs="text", outputs="html",
|
|
| 20 |
cache_examples="lazy",
|
| 21 |
concurrency_limit=30,
|
| 22 |
css=".output {font-size: 150%;}")
|
| 23 |
-
demo.launch()
|
|
|
|
| 3 |
|
| 4 |
examples = [
|
| 5 |
"Hello, world!",
|
| 6 |
+
"European Central bank has announced cuts.",
|
| 7 |
+
"This document is a summary of the European Public Assessment Report (EPAR).",
|
| 8 |
+
"En el presente documento se resume el Informe Público Europeo de Evaluación (EPAR)."]
|
| 9 |
|
| 10 |
|
| 11 |
def greet(sentence):
|
| 12 |
+
sp_ecb = spm.SentencePieceProcessor()
|
| 13 |
+
sp_ecb.load('bpe-ECB.model')
|
| 14 |
+
|
| 15 |
+
sp_emea = spm.SentencePieceProcessor()
|
| 16 |
+
sp_emea.load('bpe-EMEA.model')
|
| 17 |
+
|
| 18 |
+
return ("<div class='output'>" +
|
| 19 |
+
"<div><b>ECB dataset</b></br>" +
|
| 20 |
+
("<span style='background-color: yellow;'> • </span>".join(sp_ecb.encode_as_pieces(sentence))) +
|
| 21 |
+
"</div>" +
|
| 22 |
+
"<div style='padding-top: 1em;'><b>EMEA dataset</b></br>" +
|
| 23 |
+
("<span style='background-color: yellow;'> • </span>".join(sp_emea.encode_as_pieces(sentence))) +
|
| 24 |
+
"</div>" +
|
| 25 |
+
"</div>")
|
| 26 |
|
| 27 |
|
| 28 |
demo = gr.Interface(fn=greet, inputs="text", outputs="html",
|
|
|
|
| 31 |
cache_examples="lazy",
|
| 32 |
concurrency_limit=30,
|
| 33 |
css=".output {font-size: 150%;}")
|
| 34 |
+
demo.launch(share=True)
|
bpe.model → bpe-ECB.model
RENAMED
|
Binary files a/bpe.model and b/bpe-ECB.model differ
|
|
|
bpe-EMEA.model
ADDED
|
Binary file (316 kB). View file
|
|
|