Spaces:
Sleeping
Sleeping
gospacedev
commited on
Commit
โข
d717ae5
1
Parent(s):
c86e9f2
filter emojis
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
|
@@ -20,17 +21,19 @@ def generate_translation(prompt):
|
|
20 |
formatted_prompt = system_instructions + prompt + "[/INST]"
|
21 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
22 |
output = ""
|
|
|
23 |
|
24 |
for response in stream:
|
25 |
output += response.token.text
|
26 |
yield output
|
27 |
-
return output
|
28 |
|
29 |
|
30 |
|
31 |
with gr.Blocks() as demo:
|
32 |
-
|
33 |
-
|
|
|
34 |
translate_btn = gr.Button("Translate!")
|
35 |
translate_btn.click(fn=generate_translation, inputs=name, outputs=output, api_name="translate")
|
36 |
|
|
|
1 |
+
import re
|
2 |
import gradio as gr
|
3 |
from huggingface_hub import InferenceClient
|
4 |
|
|
|
21 |
formatted_prompt = system_instructions + prompt + "[/INST]"
|
22 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
23 |
output = ""
|
24 |
+
emoji_pattern = r"[^\u0021-\u007E\u00A0-\uD7FF\uE000-\uFDCF\uFF00-\uFFEF\u10000-\u10FFFF\u0300-\u036F\u1F00-\u1F1F\u1F20-\u1F7F\u2600-\u26FF\u2700-\u27BF]+?"
|
25 |
|
26 |
for response in stream:
|
27 |
output += response.token.text
|
28 |
yield output
|
29 |
+
return re.findall(emoji_pattern, output)
|
30 |
|
31 |
|
32 |
|
33 |
with gr.Blocks() as demo:
|
34 |
+
with gr.Row():
|
35 |
+
name = gr.Textbox(label="Enter text")
|
36 |
+
output = gr.Textbox(label="Translation")
|
37 |
translate_btn = gr.Button("Translate!")
|
38 |
translate_btn.click(fn=generate_translation, inputs=name, outputs=output, api_name="translate")
|
39 |
|
haa.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
# Example usage:
|
6 |
+
text = "This is a string with t๐ค๐๐ext and emojis๐๐๐๐"
|
7 |
+
filtered_emojis = filter_emojis(text)
|
8 |
+
|
9 |
+
print(f"Original text: {text}")
|
10 |
+
print(f"Filtered emojis: {filtered_emojis}")
|