Where text is the complete string and dic is a

  • No School
  • AA 1
  • 3
  • 100% (1) 1 out of 1 people found this document helpful

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

#where text is the complete string and dic is a dictionary def replace_all(text, dic): for i, j in dic.items():#.items will give us both key ans value pair #The syntax of replace() is:str.replace(old, new [, count]) text = text.replace(i, j)#i is key and j is value return text a = replace_all(text, dic) a 'because following are because graphical (non-control) characters defined because' import string aa=('bcz,bcz,and bcz') aa 'bcz,bcz,and bcz' new_str = str.replace(aa,'bcz','Because') print(new_str) Because,Because,and Because 3. How do you deal with the English text having Hindi words in between?
Image of page 2
Ans: 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). Q.4Write R code to connect with this public API - Ans: rm(list = ls()) library(usethis) install.packages("devtools") library(usethis) library(httr) library(jsonlite) Query<-("") result<-GET(url=Query) content(result) class(data) # Shows raw data which is not structured and readable jsonRespText<-content(result,as="text") jsonRespText
Image of page 3

You've reached the end of your free preview.

Want to read all 3 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