09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7

Analytics at Scale

Here is the WordCounterBDAS utility class:

import java.util.ArrayList;

import java.util.HashMap;

/**

*

*/

/**

* @author SayanM

*

*/

public final class WordCounterBDAS extends RootBDAS{

@Override

HashMap<String, ArrayList<String>> mapper_task

(String line) {

// TODO Auto-generated method stub

String[] words = line.split(" ");

HashMap<String, ArrayList<String>> result = new

HashMap<String, ArrayList<String>>();

for(String w : words)

{

if(result.containsKey(w))

{

ArrayList<String> vals = result.

get(w);

vals.add("1");

result.put(w, vals);

}

else

151

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!