Spaces:
Sleeping
Sleeping
aldan.creo
commited on
Commit
·
4c7678c
1
Parent(s):
ec5f144
App update
Browse files- .gitignore +1 -0
- app.py +22 -1
- requirements.txt +1 -1
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.venv
|
app.py
CHANGED
@@ -4,11 +4,32 @@ Also show tho checkboxes for replace_chars and replace_spaces.
|
|
4 |
"""
|
5 |
|
6 |
import gradio as gr
|
|
|
7 |
|
8 |
from silver_speak.homoglyphs.random_attack import (
|
9 |
random_attack as random_homoglyphs_attack,
|
10 |
)
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
EXAMPLE_TEXT_1 = "Dr. Capy Cosmos, a capybara unlike any other, astounded the scientific community with his groundbreaking research in astrophysics. With his keen sense of observation and unparalleled ability to interpret cosmic data, he uncovered new insights into the mysteries of black holes and the origins of the universe. As he peered through telescopes with his large, round eyes, fellow researchers often remarked that it seemed as if the stars themselves whispered their secrets directly to him. Dr. Cosmos not only became a beacon of inspiration to aspiring scientists but also proved that intellect and innovation can be found in the most unexpected of creatures."
|
14 |
EXAMPLE_TEXT_2 = "What are the standards required of offered properties? Properties need to be habitable and must meet certain health and safety standards, which the local authority can discuss with you. These standards have been agreed by the Department of Housing, Local Government and Heritage. The local authority will assess your property to make sure it meets the standards. If the property does not meet the standards, the local authority will explain why and can discuss what could be done to bring the property up to standard. Some properties may not be suitable for all those in need of accommodation, due to location or other reasons. However, every effort will be made by the local authority to ensure that offered properties are matched to appropriate beneficiaries."
|
|
|
4 |
"""
|
5 |
|
6 |
import gradio as gr
|
7 |
+
import random
|
8 |
|
9 |
from silver_speak.homoglyphs.random_attack import (
|
10 |
random_attack as random_homoglyphs_attack,
|
11 |
)
|
12 |
+
|
13 |
+
|
14 |
+
def random_deletion_attack(original_text, percentage=0.1, random_seed=42):
|
15 |
+
"""
|
16 |
+
Inserts random deletion characters into the text.
|
17 |
+
"""
|
18 |
+
# TODO: Include this in the SilverSpeak library
|
19 |
+
|
20 |
+
# Use the unicode DEL character
|
21 |
+
DELETION_CHAR = "\u007F"
|
22 |
+
# Insert the deletion character in random places in the text. The number of characters to insert is a percentage of the length of the text.
|
23 |
+
random.seed(random_seed)
|
24 |
+
|
25 |
+
# Insert the deletion characters
|
26 |
+
text = original_text
|
27 |
+
for i in range(int(len(text) * percentage)):
|
28 |
+
position = random.randint(0, len(text))
|
29 |
+
text = text[:position] + DELETION_CHAR + text[position:]
|
30 |
+
|
31 |
+
return text
|
32 |
+
|
33 |
|
34 |
EXAMPLE_TEXT_1 = "Dr. Capy Cosmos, a capybara unlike any other, astounded the scientific community with his groundbreaking research in astrophysics. With his keen sense of observation and unparalleled ability to interpret cosmic data, he uncovered new insights into the mysteries of black holes and the origins of the universe. As he peered through telescopes with his large, round eyes, fellow researchers often remarked that it seemed as if the stars themselves whispered their secrets directly to him. Dr. Cosmos not only became a beacon of inspiration to aspiring scientists but also proved that intellect and innovation can be found in the most unexpected of creatures."
|
35 |
EXAMPLE_TEXT_2 = "What are the standards required of offered properties? Properties need to be habitable and must meet certain health and safety standards, which the local authority can discuss with you. These standards have been agreed by the Department of Housing, Local Government and Heritage. The local authority will assess your property to make sure it meets the standards. If the property does not meet the standards, the local authority will explain why and can discuss what could be done to bring the property up to standard. Some properties may not be suitable for all those in need of accommodation, due to location or other reasons. However, every effort will be made by the local authority to ensure that offered properties are matched to appropriate beneficiaries."
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
silver_speak @ git+https://github.com/ACMCMC/silverspeak.git@
|
2 |
gradio==4.36.1
|
|
|
1 |
+
silver_speak @ git+https://github.com/ACMCMC/silverspeak.git@1ea147cbe7b50dd621aa51668033e95ec3b75203
|
2 |
gradio==4.36.1
|