import pandas as pd # File path to the input CSV file input_file_path = '../original_data/data.csv' # Output file path output_file_path = 'top_50_urdu.json' # Load the CSV file into a Pandas DataFrame df = pd.read_csv(input_file_path, encoding='utf-8') # count the number of rows num_rows = df.shape[0] print(f"Number of rows: {num_rows}") # Count the number of rows where both column values are the same same_values_count = df[df['Urdu text'] == df['Roman-Urdu text']].shape[0] print(f"Number of rows where both column values are the same: {same_values_count}") # count the number of rows where both column values are different different_values_count = df[df['Urdu text'] != df['Roman-Urdu text']].shape[0] print(f"Number of rows where both column values are different: {different_values_count}") # count the number of unique Urdu sentences unique_urdu_sentences = df['Urdu text'].nunique() print(f"Number of unique Urdu sentences: {unique_urdu_sentences}") # count the number of unique Roman-Urdu sentences unique_roman_urdu_sentences = df['Roman-Urdu text'].nunique() print(f"Number of unique Roman-Urdu sentences: {unique_roman_urdu_sentences}") # count the number of rows where the Urdu and Roman-Urdu sentences do not appear anywhere else together unique_pairs = df.groupby(['Urdu text', 'Roman-Urdu text']).size().reset_index(name='count') unique_pairs = unique_pairs[unique_pairs['count'] == 1].shape[0] print(f"Number of rows where the combination occurs only once in the whole dataset: {unique_pairs}") # count the number of unique pairs of Urdu and Roman-Urdu sentences unique_pairs = df.drop_duplicates().shape[0] print(f"Number of unique pairs of Urdu and Roman-Urdu sentences: {unique_pairs}") # count the number of rows where the Urdu sentence appears only once in the dataset urdu_sentence_counts = df['Urdu text'].value_counts() urdu_sentence_counts = urdu_sentence_counts[urdu_sentence_counts == 1].shape[0] print(f"Number of rows where the Urdu sentence appears only once in the dataset: {urdu_sentence_counts}") # count the number of rows where the Roman-Urdu sentence appears only once in the dataset roman_urdu_sentence_counts = df['Roman-Urdu text'].value_counts() roman_urdu_sentence_counts = roman_urdu_sentence_counts[roman_urdu_sentence_counts == 1].shape[0] print(f"Number of rows where the Roman-Urdu sentence appears only once in the dataset: {roman_urdu_sentence_counts}") # count the number of where the urdu sentences appear more than once but less than 11 times in the whole dataset urdu_sentence_counts = df['Urdu text'].value_counts() urdu_sentence_counts = urdu_sentence_counts[(urdu_sentence_counts > 1) & (urdu_sentence_counts <= 10)].shape[0] print(f"Number of rows where the Urdu sentence appears more than once but less than 11 times in the whole dataset: {urdu_sentence_counts}")