File size: 1,206 Bytes
5046606
3fcd866
5046606
 
 
 
 
a7b34d0
dcda834
 
3fcd866
dcda834
 
 
3fcd866
 
 
dcda834
 
 
 
 
 
 
 
 
 
3fcd866
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
import numpy as np
import gradio as gr
import os
import pandas as pd
from datasets import load_dataset

Secret_token = os.getenv('token')

dataset = load_dataset('FDSRashid/hadith_info',data_files = 'Basic_Edge_Information.csv', token = Secret_token, split = 'train')
edge_info = dataset.to_pandas()

def subset_city_year(year = 50, city = ['المدينه', 'بغداد', 'كوفة', 'بصرة']):
  edges = edge_info[(edge_info['Year'] == year) & (edge_info['City'].isin(city))]
  return edges



def get_narrators(year = 50, city =  ['المدينه', 'بغداد', 'كوفة', 'بصرة']):
  df = subset_city_year(year, city)
  narrators = edge_info[edge_info['Edge_ID'].isin(df['ID'])]
  return narrators['Edge_Name'].reset_index().drop('index', axis = 1).rename(columns = {'Edge_Name': 'Teacher To Student'})

app = gradio.Interface(get_narrators,
             [gradio.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
                        gradio.Slider(min_year, max_year, value = 0, label = 'Begining', info = 'Choose The Year to Retrieve Narrators'),
                        ],
                       gr.Dataframe()).launch()