Skip to content

Instantly share code, notes, and snippets.

View milindjagre's full-sized avatar
💭
❤️ DATA ❤️

Milind Jagre milindjagre

💭
❤️ DATA ❤️
View GitHub Profile
@milindjagre
milindjagre / MachETweets.ipynb
Created November 20, 2019 14:17
Mustang Mach-E tweets extraction using Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@milindjagre
milindjagre / getNumberOfSentences.txt
Created December 17, 2018 21:26
This method returns the number of sentences used by eminem in his lyrical career.
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 December 17, 2018 21:13
This method gives away the sentiment of the input lyrics.
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 December 17, 2018 21:41
This method returns the top 10 most used negative words in Eminem's lyrics.
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 December 17, 2018 21:40
This method returns the top 10 most used positive words in Eminem's lyrics.
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 December 17, 2018 21:40
This method returns the people names from the input lyrics.
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 December 17, 2018 20:27
This method returns the HashMap which is sorted by Values.
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 December 17, 2018 20:21
This method returns the HashMap of words and their respective counts.
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 December 17, 2018 19:08
This method returns a list with all the STOP WORDS.
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 September 13, 2017 10:53
This SQL file is used for creating a Hive table for performing the ORDER BY operation
create table post50 (
order_id int,
order_date string,
order_amt int,
order_status string
)
row format delimited
fields terminated by ','
stored as textfile;