Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| create table post50 ( | |
| order_id int, | |
| order_date string, | |
| order_amt int, | |
| order_status string | |
| ) | |
| row format delimited | |
| fields terminated by ',' | |
| stored as textfile; |
NewerOlder