Spaces:
Running
on
Zero
Running
on
Zero
Pulled out sample texts
Browse files- app.py +21 -28
- data/sample1_en.txt +8 -0
- data/sample2_en.txt +6 -0
- data/sample_es.txt +7 -0
- data/sample_fr.txt +5 -0
app.py
CHANGED
|
@@ -36,6 +36,23 @@ WORKING_DIR = "./sample"
|
|
| 36 |
EXAMPLE_CACHE_FILE = os.path.join(CACHE_DIR, "first_example_cache.pkl")
|
| 37 |
GRAPHML_FILE = WORKING_DIR + "/graph_chunk_entity_relation.graphml"
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# Create cache directory if it doesn't exist
|
| 40 |
os.makedirs(CACHE_DIR, exist_ok=True)
|
| 41 |
os.makedirs(WORKING_DIR, exist_ok=True)
|
|
@@ -305,34 +322,10 @@ def process_and_visualize(text, model_name, progress=gr.Progress()):
|
|
| 305 |
|
| 306 |
# Example texts
|
| 307 |
EXAMPLES = [
|
| 308 |
-
|
| 309 |
-
[handle_text(
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
hospitals and the country's major sports complex. Their eldest daughter, Leyla, editor of Baku magazine, and her sister, Arzu,
|
| 313 |
-
have financial stakes in a firm that won rights to mine for gold in the western village of Chovdar and Azerfon, the country's largest mobile phone business.
|
| 314 |
-
Arzu is also a significant shareholder in SW Holding, which controls nearly every operation related to Azerbaijan Airlines (“Azal”), from meals to airport taxis.
|
| 315 |
-
Both sisters and brother Heydar own property in Dubai valued at roughly $75 million in 2010;
|
| 316 |
-
Heydar is the legal owner of nine luxury mansions in Dubai purchased for some $44 million.""")],
|
| 317 |
-
|
| 318 |
-
[handle_text("""Les jardins du Luxembourg, situés au cœur du sixième arrondissement de Paris, offrent un véritable havre de paix aux citadins pressés.
|
| 319 |
-
Créés au début du dix-septième siècle sur l'initiative de Marie de Médicis, ces jardins à la française s'étendent sur vingt-trois hectares
|
| 320 |
-
et abritent le Palais du Luxembourg, siège du Sénat français. Les promeneurs peuvent y admirer les parterres de fleurs soigneusement entretenus,
|
| 321 |
-
les bassins ornés de statues mythologiques, et les allées bordées de marronniers centenaires. Chaque matin, les jardiniers s'affairent à tailler
|
| 322 |
-
les buis et à arroser les rosiers, perpétuant ainsi une tradition d'excellence horticole qui fait la fierté de la capitale française.""")],
|
| 323 |
-
|
| 324 |
-
[handle_text("""In a groundbreaking development, researchers at the Massachusetts Institute of Technology (MIT) have unveiled a new type of battery that promises to revolutionize energy storage.
|
| 325 |
-
This lithium-sulfur battery boasts a significantly higher energy density compared to traditional lithium-ion batteries, potentially extending the range of electric vehicles and the lifespan of portable electronics.
|
| 326 |
-
The team, led by Dr. Jane Smith, has been working on this technology for over five years, overcoming numerous challenges related to sulfur's conductivity and stability.
|
| 327 |
-
The new battery design incorporates a novel cathode structure that enhances performance and durability.
|
| 328 |
-
With successful prototype tests already completed, the researchers are now collaborating with industry partners to scale up production and bring this innovative solution to market within the next few years.""")],
|
| 329 |
-
|
| 330 |
-
[handle_text("""Los mercados callejeros son el corazón vibrante de muchas ciudades alrededor del mundo. Desde los coloridos puestos de frutas y verduras frescas
|
| 331 |
-
hasta los aromas tentadores de la comida callejera, estos espacios no solo ofrecen productos locales, sino también una experiencia cultural única.
|
| 332 |
-
En ellos, es común escuchar el regateo amable entre vendedores y clientes, mientras los sonidos de la música tradicional se mezclan con el bullicio
|
| 333 |
-
de la multitud. Además, son lugares ideales para descubrir artesanías hechas a mano, como tejidos, cerámicas o joyería, que reflejan la creatividad
|
| 334 |
-
y las tradiciones de la región. Visitar un mercado callejero es sumergirse en la esencia misma de una comunidad, donde cada rincón cuenta una historia
|
| 335 |
-
y cada sabor evoca recuerdos.""")],
|
| 336 |
]
|
| 337 |
|
| 338 |
def generate_first_example():
|
|
|
|
| 36 |
EXAMPLE_CACHE_FILE = os.path.join(CACHE_DIR, "first_example_cache.pkl")
|
| 37 |
GRAPHML_FILE = WORKING_DIR + "/graph_chunk_entity_relation.graphml"
|
| 38 |
|
| 39 |
+
# Load the sample texts
|
| 40 |
+
text_en_file1 = "./data/sample1_en.txt"
|
| 41 |
+
with open(text_en_file1, 'r', encoding='utf-8') as file:
|
| 42 |
+
text1_en = file.read()
|
| 43 |
+
|
| 44 |
+
text_en_file2 = "./data/sample2_en.txt"
|
| 45 |
+
with open(text_en_file2, 'r', encoding='utf-8') as file:
|
| 46 |
+
text2_en = file.read()
|
| 47 |
+
|
| 48 |
+
text_fr_file = "./data/sample_fr.txt"
|
| 49 |
+
with open(text_fr_file, 'r', encoding='utf-8') as file:
|
| 50 |
+
text_fr = file.read()
|
| 51 |
+
|
| 52 |
+
text_es_file = "./data/sample_es.txt"
|
| 53 |
+
with open(text_es_file, 'r', encoding='utf-8') as file:
|
| 54 |
+
text_es = file.read()
|
| 55 |
+
|
| 56 |
# Create cache directory if it doesn't exist
|
| 57 |
os.makedirs(CACHE_DIR, exist_ok=True)
|
| 58 |
os.makedirs(WORKING_DIR, exist_ok=True)
|
|
|
|
| 322 |
|
| 323 |
# Example texts
|
| 324 |
EXAMPLES = [
|
| 325 |
+
[handle_text(text1_en)],
|
| 326 |
+
[handle_text(text_fr)],
|
| 327 |
+
[handle_text(text2_en)],
|
| 328 |
+
[handle_text(text_es)],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
]
|
| 330 |
|
| 331 |
def generate_first_example():
|
data/sample1_en.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The family of Azerbaijan President Ilham Aliyev leads a charmed, glamorous life, thanks in part to financial interests in almost every sector of the economy.
|
| 2 |
+
His wife, Mehriban, comes from the privileged and powerful Pashayev family that owns banks, insurance and construction companies,
|
| 3 |
+
a television station and a line of cosmetics. She has led the Heydar Aliyev Foundation, Azerbaijan's pre-eminent charity behind the construction of schools,
|
| 4 |
+
hospitals and the country's major sports complex. Their eldest daughter, Leyla, editor of Baku magazine, and her sister, Arzu,
|
| 5 |
+
have financial stakes in a firm that won rights to mine for gold in the western village of Chovdar and Azerfon, the country's largest mobile phone business.
|
| 6 |
+
Arzu is also a significant shareholder in SW Holding, which controls nearly every operation related to Azerbaijan Airlines (“Azal”), from meals to airport taxis.
|
| 7 |
+
Both sisters and brother Heydar own property in Dubai valued at roughly $75 million in 2010;
|
| 8 |
+
Heydar is the legal owner of nine luxury mansions in Dubai purchased for some $44 million.
|
data/sample2_en.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
In a groundbreaking development, researchers at the Massachusetts Institute of Technology (MIT) have unveiled a new type of battery that promises to revolutionize energy storage.
|
| 2 |
+
This lithium-sulfur battery boasts a significantly higher energy density compared to traditional lithium-ion batteries, potentially extending the range of electric vehicles and
|
| 3 |
+
the lifespan of portable electronics. The team, led by Dr. Jane Smith, has been working on this technology for over five years, overcoming numerous challenges related to
|
| 4 |
+
sulfur's conductivity and stability. The new battery design incorporates a novel cathode structure that enhances performance and durability.
|
| 5 |
+
With successful prototype tests already completed, the researchers are now collaborating with industry partners to scale up production and bring
|
| 6 |
+
this innovative solution to market within the next few years.
|
data/sample_es.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
El cambio climático es uno de los mayores desafíos que enfrenta la humanidad en el siglo XXI. Sus efectos, como el aumento de las temperaturas,
|
| 2 |
+
el derretimiento de los glaciares y la mayor frecuencia de fenómenos meteorológicos extremos, ya se hacen sentir en todo el mundo.
|
| 3 |
+
Este problema global requiere de acciones coordinadas entre gobiernos, empresas y ciudadanos para reducir las emisiones de gases de efecto invernadero y
|
| 4 |
+
promover el uso de energías renovables. Pequeños gestos, como reciclar, ahorrar energía o utilizar el transporte público, pueden marcar una gran diferencia
|
| 5 |
+
si se adoptan a gran escala. Además, la educación ambiental y la concienciación social son herramientas fundamentales para construir un futuro más sostenible.
|
| 6 |
+
Cada persona tiene un papel importante en la protección del planeta, y es responsabilidad de todos actuar con urgencia para preservar los recursos naturales y
|
| 7 |
+
garantizar un entorno saludable para las generaciones futuras.
|
data/sample_fr.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Les jardins du Luxembourg, situés au cœur du sixième arrondissement de Paris, offrent un véritable havre de paix aux citadins pressés.
|
| 2 |
+
Créés au début du dix-septième siècle sur l'initiative de Marie de Médicis, ces jardins à la française s'étendent sur vingt-trois hectares
|
| 3 |
+
et abritent le Palais du Luxembourg, siège du Sénat français. Les promeneurs peuvent y admirer les parterres de fleurs soigneusement entretenus,
|
| 4 |
+
les bassins ornés de statues mythologiques, et les allées bordées de marronniers centenaires. Chaque matin, les jardiniers s'affairent à tailler
|
| 5 |
+
les buis et à arroser les rosiers, perpétuant ainsi une tradition d'excellence horticole qui fait la fierté de la capitale française.
|