Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
❤️ DATA ❤️

Milind Jagre milindjagre

💭
❤️ DATA ❤️
View GitHub Profile
@milindjagre
milindjagre / WordToPdf.java
Created Apr 13, 2016
This java file will convert word file into pdf file. Word to Pdf converter using JAVA API.
View WordToPdf.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.milind.word.to.pdf;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
@milindjagre
milindjagre / MachETweets.ipynb
Created Nov 20, 2019
Mustang Mach-E tweets extraction using Python
View MachETweets.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / 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 / 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;
You can’t perform that action at this time.