2 Write R and python code to replace bcz with because in whole text Answer R

2 write r and python code to replace bcz with because

This preview shows page 1 - 2 out of 2 pages.

2. Write R and python code to replace “bcz” with “because” in whole text? Answer: R code: #In R Sub() function can be used to find the text and with help of gsub(), text can be replaced: test <- "high five to edwisor bcz they are doing good work" gsub("bcz", "because", test) (PS: I HAVE ATTACHED SEPARATE R CODE FILE.) Python Code: In Python same can be achieved by using string.replace() function. our_str = ‘Bcz i love bollywood’ import string
Image of page 1
new_str = str.replace(our_str, 'Bcz', 'Because') print(new_str) (PS: I HAVE ATTACHED SEPARATE PYTHON CODE FILE.) 3. How do you deal with the English text having Hindi words in between? Answer: There are two ways to treat Hindi text between English words: Translate the Hindi Words to English: Lookup all the words in English dictionary and tag them such as Remove the Hindi Words: Using the words corpus from NLTK ( The Natural Language Toolkit). 4. Write R code to connect with this public API - Answer: Create a account on to get the api key Library(httr) Query <- Out<- GET(url=Query)
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes