शुरू करेंमुफ़्त में शुरू करें

DataFrame में TED Talks की सफाई

इस अभ्यास में, हम पहले चैप्टर वाले TED Talks पर फिर से काम करेंगे. आपके पास ted नाम का एक dataframe है जिसमें 5 TED Talks हैं. आपका काम है इन talks को पहले सीखी गई techniques से साफ करना: एक preprocess फंक्शन लिखिए और उसे dataframe के transcript फीचर पर apply कीजिए.

Stopwords की सूची stopwords के रूप में उपलब्ध है.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में NLP के लिए Feature Engineering

पाठ्यक्रम देखें

अभ्यास निर्देश

  • text के लिए Doc ऑब्जेक्ट बनाइए. फिलहाल disable argument को ignor कीजिए.
  • list comprehension का इस्तेमाल करते हुए lemma_ attribute से lemmas बनाइए.
  • if condition में isalpha() का उपयोग करके non-alphabetic कैरेक्टर हटाइए.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Function to preprocess text
def preprocess(text):
  	# Create Doc object
    doc = nlp(____, disable=['ner', 'parser'])
    # Generate lemmas
    lemmas = [token.____ for token in doc]
    # Remove stopwords and non-alphabetic characters
    a_lemmas = [lemma for lemma in lemmas 
            if lemma.____ and lemma not in stopwords]
    
    return ' '.join(a_lemmas)
  
# Apply preprocess to ted['transcript']
ted['transcript'] = ted['transcript'].apply(____)
print(ted['transcript'])
कोड संपादित करें और चलाएँ