1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.root;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Vector;


/**
 *
 * @author omega9
 */
public class SentimentList {
    
    public HashMap<String, Vector<Float>> list;

    public void loadSentimentList(String filename) {

        // Load sentiments from a the sentiment list file. Access the file and load the values into a dictionary.
        String filein = filename;

        String[] splited;
        Vector<String> words = new Vector<String>();
        Vector<Float> vals = new Vector<Float>();
        list = new HashMap<String, Vector<Float>>();

        try {

            FileInputStream fin = new FileInputStream(filein);
            BufferedReader br = new BufferedReader(new InputStreamReader(fin));
        
            String strLine;
            int k = 0;
            
            //while ((strLine = br.readLine()) != null) {
            for (k = 0; k < 10000; k++) {    
                
                strLine = br.readLine();

                splited = strLine.split("\t");
                
                vals.clear();         

                vals.add(Float.valueOf(splited[2]));
                vals.add(Float.valueOf(splited[3]));

                for (int i = 4; i < splited.length - 1; i++) {
                    words.add(splited[i].split("#")[0]);
                }

                for (int i = 0; i < words.size(); i++) {
                    
                        list.put(words.elementAt(i), vals);
                }
                
                System.out.println("Done reading line " + k + "\n\n");
            }
            br.close();
            fin.close();
        } catch (Exception e) { System.out.println("\n\nException in Sentiment List - " + e + "\n\n");}
    }
    
    public Vector<Float> getSentimentScore(String word) {
        
        Vector<Float> vals = new Vector<Float>();
        
        vals = list.get(word);
        
        return vals;
        
    }
}