Skip to content

Commit

Permalink
move files to src, and read as Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
kevenli committed Aug 9, 2015
1 parent 501a5ea commit 2b1133f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/com/gta/affective/Segment.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.io.BufferedReader;
//import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
Expand Down Expand Up @@ -47,8 +49,9 @@ public Segment() {
*/
public void initNegtive() {
try {
File file = new File("negtive.txt");
BufferedReader br = Files.newBufferedReader(file.toPath(), Charset.forName("GBK"));
InputStream input = getClass().getResourceAsStream("negtive.txt");
InputStreamReader reader = new InputStreamReader(input, Charset.forName("GBK"));
BufferedReader br = new BufferedReader(reader);
String s = null;
if ((s = br.readLine())!= null) {
negtiveEnum = s.split(",");
Expand All @@ -66,8 +69,9 @@ public void initNegtive() {
public void initConjunction() {
conSet = new HashSet<ConjunctionClassify>();
try {
File file = new File("conjunction.txt");
BufferedReader br = Files.newBufferedReader(file.toPath(), Charset.forName("GBK"));
InputStream input = getClass().getResourceAsStream("conjunction.txt");
InputStreamReader reader = new InputStreamReader(input, Charset.forName("GBK"));
BufferedReader br = new BufferedReader(reader);
String s = null;
while ((s = br.readLine())!= null) {
String []elementEnum = s.split("\t");
Expand All @@ -87,8 +91,9 @@ public void initConjunction() {
public void initPolar() {
polarMap = new HashMap<String, Dict>();
try {
File file = new File("dict.txt");
BufferedReader br = Files.newBufferedReader(file.toPath(), Charset.forName("GBK"));
InputStream input = getClass().getResourceAsStream("dict.txt");
InputStreamReader reader = new InputStreamReader(input, Charset.forName("GBK"));
BufferedReader br = new BufferedReader(reader);
String s = null;
while ((s = br.readLine()) != null) {
String []element = s.split("\t");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2b1133f

Please sign in to comment.