100%(15)15 out of 15 people found this document helpful
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
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 asRemove 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 onto get the api keyLibrary(httr)Query <-Out<- GET(url=Query)