txtr fcontents fread printfcontents fclose Output because following are because

Txtr fcontents fread printfcontents fclose output

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

f = open('test.txt','r') f_contents = f.read() print(f_contents) f.close() Output because following are because graphical (non-control) characters defined because ------------------------------------------------------- #Replace using dictionary if there are more than one word to replace
Image of page 2
#Building dictionary consisting of key as word to match and value as word to replace dic = {'bcz':'because'} text = ('bcz following are bcz graphical (non-control) characters defined bcz') #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 Out[8]: 'because following are because graphical (non-control) characters defined because' 3. How do you deal with the English text having Hindi words in between? Normalize the word tokens, Transliterate the words in Hindi language script (Devanagari) and look up the words in Hindi dictionary for its existence. Check for spelling variations. If found tag them as such. Lookup all the words in English dictionary and tag them as such. If there is tie with the other language then use word frequency probability to break the tie. Perform the POS Tag analysis to get the words tagged as either noun, adjective, adverb and verb. Loop up the sentiment scores from sentiwordnet of each languages (Hindi/English), for each token based on their language tags. Use wordnet to get the identifier and use senti-wordnet to get the sentiment associated with those words along with the corresponding tags we found in the POS tag analysis Convert the words in to features: Remove stop words Remove the words senti-scores that are not important such as everything except adjective and adverbs, since they are the most important ones where sentiments are concerned Create an ngram feature to hook words with its context Feed it to a classifier for training and then test on the subject to calculate accuracy
Image of page 3
4. Write R code to connect with this public API - File Attached 5. What are the different methods to deploy a model into production system?
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

  • Fall '19
  • Hindi, Devanagari, BCZ

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture