File size: 706 Bytes
292a188
 
7711e2d
 
292a188
7711e2d
d7671ef
428c884
 
 
 
f6734bb
292a188
 
 
 
 
 
 
 
 
 
 
655616c
292a188
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

import gradio as gr
from datasets import load_dataset


# Load the dataset
dataset = load_dataset("mohres/The_Arabic_E-Book_Corpus")
def filter_arabic_novels():
    # Select only rows containing novel-like words
    filtered_data = dataset['train'].filter(lambda x: "رواية" in x['text'])
    return filtered_data


# Function to display the first row text
def get_first_text():
    try:
        return dataset['train'][0]['text']
    except Exception as e:
        return str(e)


# Create a Gradio Interface
interface = gr.Interface(
    fn=lambda: filter_arabic_novels()[0]['text'],  # Only show first filtered sample
    inputs=[],
    outputs="text",
)

# Launch the interface
interface.launch()