Skip to content

Instantly share code, notes, and snippets.

💭
❤️EMINEM❤️

Milind Jagre milindjagre

💭
❤️EMINEM❤️
Block or report user

Report or block milindjagre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@milindjagre
milindjagre / getNumberOfSentences.txt
Created Dec 17, 2018
This method returns the number of sentences used by eminem in his lyrical career.
View getNumberOfSentences.txt
public static int getNumberOfSentences(SentenceModel sentenceModel,
String input) throws IOException {
SentenceDetectorME detector = new SentenceDetectorME(sentenceModel);
String sentences[] = detector.sentDetect(input);
return sentences.length;
}
String[] inputFilePathArray = new String[4];
inputFilePathArray[0] = "C:\\input1.txt";
inputFilePathArray[1] = "C:\\input2.txt";
@milindjagre
milindjagre / classifyNewText.txt
Created Dec 17, 2018
This method gives away the sentiment of the input lyrics.
View classifyNewText.txt
public static int classifyNewText(DoccatModel sentimentModel, String input)
throws IOException {
DocumentCategorizerME myCategorizer = new DocumentCategorizerME(
sentimentModel);
double[] outcomes = myCategorizer.categorize(input);
return Integer.parseInt(myCategorizer.getBestCategory(outcomes));
}
String[] inputFilePathArray = new String[4];
inputFilePathArray[0] = "C:\\input1.txt";
@milindjagre
milindjagre / getNegativeWords.txt
Last active Dec 17, 2018
This method returns the top 10 most used negative words in Eminem's lyrics.
View getNegativeWords.txt
public static List<String> getNegativeWords() throws IOException {
List<String> outputList = new ArrayList<String>();
BufferedReader br = new BufferedReader(new FileReader(
"C:\\negative-words.txt"));
String line = null;
while ((line = br.readLine()) != null) {
outputList.add(line);
}
br.close();
return outputList;
@milindjagre
milindjagre / getPositiveWords.txt
Last active Dec 17, 2018
This method returns the top 10 most used positive words in Eminem's lyrics.
View getPositiveWords.txt
public static List<String> getPositiveWords() throws IOException {
List<String> outputList = new ArrayList<String>();
BufferedReader br = new BufferedReader(new FileReader(
"C:\\positive-words.txt"));
String line = null;
while ((line = br.readLine()) != null) {
outputList.add(line);
}
br.close();
return outputList;
@milindjagre
milindjagre / getPeople.txt
Last active Dec 17, 2018
This method returns the people names from the input lyrics.
View getPeople.txt
public static List<String> getPeople(String sentence) {
TokenNameFinderModel model = null;
try {
model = new TokenNameFinderModel(new File("C:\\en-ner-person.bin"));
} catch (InvalidFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
NameFinderME finder = new NameFinderME(model);
@milindjagre
milindjagre / sortHashMapByValues.txt
Created Dec 17, 2018
This method returns the HashMap which is sorted by Values.
View sortHashMapByValues.txt
public static LinkedHashMap<String, Integer> sortHashMapByValues(
Map<String, Integer> wordCountMap) {
List<String> mapKeys = new ArrayList<String>(wordCountMap.keySet());
List<Integer> mapValues = new ArrayList<Integer>(wordCountMap.values());
Collections.sort(mapValues, Collections.reverseOrder());
Collections.sort(mapKeys);
LinkedHashMap<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
Iterator<Integer> valueIt = mapValues.iterator();
while (valueIt.hasNext()) {
Integer val = valueIt.next();
@milindjagre
milindjagre / getWordCountMap.txt
Last active Dec 17, 2018
This method returns the HashMap of words and their respective counts.
View getWordCountMap.txt
Map<String, Integer> wordCountMap = new HashMap<String, Integer>();
String[] inputFilePathArray = new String[4];
inputFilePathArray[0] = "C:\\input1.txt";
inputFilePathArray[1] = "C:\\input2.txt";
inputFilePathArray[2] = "C:\\input3.txt";
inputFilePathArray[3] = "C:\\input4.txt";
for (String inputFilePath : inputFilePathArray) {
BufferedReader br = new BufferedReader(
new FileReader(inputFilePath));
String line = null, mapKey = null;
@milindjagre
milindjagre / getStopWords.txt
Created Dec 17, 2018
This method returns a list with all the STOP WORDS.
View getStopWords.txt
public static List<String> getStopWords() throws IOException {
List<String> outputList = new ArrayList<String>();
BufferedReader br = new BufferedReader(new FileReader(
"C:\\nlp_en_stop_words.txt"));
String line = null;
while ((line = br.readLine()) != null) {
outputList.add(line);
}
br.close();
return outputList;
@milindjagre
milindjagre / post50.sql
Created Sep 13, 2017
This SQL file is used for creating a Hive table for performing the ORDER BY operation
View post50.sql
create table post50 (
order_id int,
order_date string,
order_amt int,
order_status string
)
row format delimited
fields terminated by ','
stored as textfile;
@milindjagre
milindjagre / post50.csv
Created Sep 11, 2017
this file is used for demonstrating how to perform the sorting operation across multiple reducers
View post50.csv
1 2013-07-25 00:00:00.0 11599 CLOSED
2 2013-07-25 00:00:00.0 256 PENDING_PAYMENT
3 2013-07-25 00:00:00.0 12111 COMPLETE
4 2013-07-25 00:00:00.0 8827 CLOSED
5 2013-07-25 00:00:00.0 11318 COMPLETE
6 2013-07-25 00:00:00.0 7130 COMPLETE
7 2013-07-25 00:00:00.0 4530 COMPLETE
8 2013-07-25 00:00:00.0 2911 PROCESSING
9 2013-07-25 00:00:00.0 5657 PENDING_PAYMENT
10 2013-07-25 00:00:00.0 5648 PENDING_PAYMENT
You can’t perform that action at this time.