raoufjat commited on
Commit
292a188
·
verified ·
1 Parent(s): 7711e2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -1,14 +1,26 @@
 
 
1
  from datasets import load_dataset
2
 
 
3
  # Load the dataset
4
  dataset = load_dataset("MohamedRashad/arabic-books")
5
 
6
- # Print the first text sample from the 'train' split
7
- try:
8
- # Accessing the first row safely
9
- first_text = dataset['train'][0]['text']
10
- print("First text sample in the 'train' split:")
11
- print(first_text)
12
- except Exception as e:
13
- # If anything goes wrong, print the exception
14
- print("Error while accessing the data:", e)
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
  from datasets import load_dataset
4
 
5
+
6
  # Load the dataset
7
  dataset = load_dataset("MohamedRashad/arabic-books")
8
 
9
+
10
+ # Function to display the first row text
11
+ def get_first_text():
12
+ try:
13
+ return dataset['train'][0]['text']
14
+ except Exception as e:
15
+ return str(e)
16
+
17
+
18
+ # Create a Gradio Interface
19
+ interface = gr.Interface(
20
+ fn=get_first_text,
21
+ inputs=[],
22
+ outputs="text",
23
+ )
24
+
25
+ # Launch the interface
26
+ interface.launch()