HW4_Answer.docx - Course ID ISMG 6470 Course Name Text Analytics Student ID 108731296 Student Name Mrinal Bhat Submission Date 1 library'tm

# HW4_Answer.docx - Course ID ISMG 6470 Course Name Text...

This preview shows page 1 - 3 out of 4 pages.

Course ID: ISMG 6470 Course Name: Text Analytics Student ID: 108731296 Student Name: Mrinal Bhat Submission Date: 10/09/18 1. library('tm') library("SnowballC") my.text.location <- "C:/Users/mrina/OneDrive/Documents/Text/Assignments/A4/EnglishAbstract/" apapers <- VCorpus(DirSource(my.text.location)) class(apapers) mpapers <- tm_map(apapers, removeNumbers) mpapers <- tm_map(mpapers, removePunctuation) mpapers <- tm_map(mpapers, stemDocument, language = "en") The basic ‘tm’ function to pre-process the document and clean it for better mining. 2. ptm.tf <- DocumentTermMatrix(mpapers) n <- 1 top <- findMostFreqTerms(ptm.tf, n = n) topunlist <- unlist(top) sort(topunlist, decreasing = T)[1] The code presented here is for the Document Term Matrix. ‘findMostFreqTerms’ gives the heighest value per document, then the sorting helps in giving the exact result per document. In this case its ‘Austin.Eric_45_3’ with the word ‘the’ and value ‘79’. 3. ptm.tfidf <- DocumentTermMatrix(mpapers, control=list(weighting=function(x) {weightTfIdf(x,normalize=FALSE)})) y <- 1 top1 <- findMostFreqTerms(ptm.tfidf, n = y) top1unlist <- unlist(top1) sort(top1unlist, decreasing = T)[1]
The code presented here is for the Document Term Matrix. ‘findMostFreqTerms’ gives the heighest

#### You've reached the end of your free preview.

Want to read all 4 pages?

• Summer '19
• Summation, Aggregate data, Term Matrix. ‘findMostFreqTerms, Document Term Matrix.

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern