Datasets:

Modalities:
Text
Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:

Preprocessing the Squad v2 Dataset

#10
by pritam2014 - opened

Issues:

  • Extra White Spaces
  • Question Length is smaller
  • ** Let fix the issues:

    1. Extra white-spcaces
      Let's consider your squad_dataset v2 is stored in a pandas dataframe named df.
    def remove_whitespace(text):
        # Remove leading and trailing whitespace
        text = text.strip()
        # Replace multiple spaces with a single space
        text = ' '.join(text.split())
        return text
    df['context']=df['context'].apply(remove_whitespace)
    # Do the same for questions also
    df['question']=df['question'].apply(remove_whitespace)
    
    1. Counting and removing smaller question length.
      There are some questions having d,dd, what😃 these are useless questions so let's see how to remove them.
    def count_text_length(text):
        return len(text)
    df['context_len']=df['context'].apply(count_text_length)
    df['question_len']=df['question'].apply(count_text_length)
    # now find out the smaller length questions
    df[df['question_len']<10]
    

    You will see some useless questions you can see for the context also.

    # for keeping the useful questions
    df[df['question_len']>x] #x will be set by you means how much length you want.
    

    After that you can drop the unnecessary columns

    df.drop(columns=['question_len','context_len'],inplace=True)
    

    Thank you🎯🧡

    Sign up or log in to comment