टोकन पैटर्न कैप्चर करना

Python में Sentiment Analysis

Violeta Misheva

Data Scientist

String ऑपरेटर्स और तुलना

# जाँचता है कि string केवल अक्षरों से बनी है  
my_string.isalpha()
# जाँचता है कि string केवल digits से बनी है 
my_string.isdigit()
# जाँचता है कि string केवल alphanumeric characters से बनी है
my_string.isalnum()
Python में Sentiment Analysis

List comprehension के साथ String ऑपरेटर्स

# मूल शब्द tokenization
word_tokens = [word_tokenize(review) for review in reviews.review]
# केवल अक्षरों वाले tokens रखें
cleaned_tokens = [[word for word in item if word.isalpha()] for item in word_tokens]
len(word_tokens[0])
87
len(cleaned_tokens[0])
78
Python में Sentiment Analysis

Regular expressions

import re
my_string = '#Wonderfulday'
# # के बाद कोई भी अक्षर, छोटा या बड़ा, निकाले
x = re.search('#[A-Za-z]', my_string)
x
<re.Match object; span=(0, 2), match='#W'>
Python में Sentiment Analysis

BOW के साथ token pattern

# CountVectorizer में डिफ़ॉल्ट token pattern
'\b\w\w+\b'
# कोई विशेष token pattern निर्धारित करें
CountVectorizer(token_pattern=r'\b[^\d\W][^\d\W]+\b')
Python में Sentiment Analysis

अभ्यास करते हैं!

Python में Sentiment Analysis

Preparing Video For Download...