BaşlayınÜcretsiz Başlayın

Everything clean

Back to your Twitter sentiment analysis project! There are several types of strings that increase your sentiment analysis complexity. But these strings do not provide any useful sentiment. Among them, we can have links and user mentions.

In order to clean the tweets, you want to extract some examples first. You know that most of the times links start with http and do not contain any whitespace, e.g. https://www.datacamp.com. User mentions start with @ and can have letters and numbers only, e.g. @johnsmith3.

You write down some helpful quantifiers to help you: * zero or more times, + once or more, ? zero or once.

The list sentiment_analysis containing the text of three tweets are already loaded in your session. You can use print() to view the data in the IPython Shell.

Bu egzersiz

Regular Expressions in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Import the re module.
  • Write a regex to find all the matches of http links appearing in each tweet in sentiment_analysis. Print out the result.
  • Write a regex to find all the matches of user mentions appearing in each tweet in sentiment_analysis. Print out the result.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import re module
____

for tweet in sentiment_analysis:
	# Write regex to match http links and print out result
	print(re.____(____"____", ____))

	# Write regex to match user mentions and print out result
	print(re.____(____"____", ____))
Kodu Düzenle ve Çalıştır