Skip to content

Commit

Permalink
Fixed a couple of bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
KimSchouten committed Feb 20, 2018
1 parent 228a9e7 commit a97f035
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 61 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Expand Up @@ -14,6 +14,16 @@
</properties>

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
121 changes: 65 additions & 56 deletions src/main/java/edu/eur/absa/Framework.java
@@ -1,56 +1,65 @@
package edu.eur.absa;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

/**
* The Framework class sets up some application wide static variables and static methods that can be used
* throughout the framework
* @author Kim Schouten
*
*/
public class Framework {

/**
* Setting up some paths for the framework to use
*/
public static final String PATH = System.getProperty("user.dir")+"/";
public static final String RESOURCES_PATH = PATH+"src/main/resources/";
public static final String OUTPUT_PATH = PATH + "output/";
public static final String DATA_PATH = RESOURCES_PATH + "data/";
public static final String EXTERNALDATA_PATH = RESOURCES_PATH + "externalData/";
public static final String RAWDATA_PATH = RESOURCES_PATH + "data/raw/";
public static final String LIB_PATH = RESOURCES_PATH + "lib/";

//Debug, error, and log can be used to pipe all system output through one place.
//If you every decide you need to send your output somewhere else, you can simply
//update these methods.

public static void debug(String message){
System.out.println(message);
}
public static void error(String message){
System.err.println(message);
}
public static void log(String message){
// Logger.getGlobal().info(message);
System.out.println(message);
}

/**
* Console output is saved to a file instead of just displayed below.
* The console box has a limited amount of text it can display, so if you have much data,
* it makes sense to save it to a file instead. This can also be helpful to keep track of your experiment.
*/
public static void fileInsteadOfConsole(){
try {
PrintStream out = new PrintStream(new FileOutputStream(new File(OUTPUT_PATH + System.currentTimeMillis() + "_console.txt")));
System.setOut(out);

} catch (IOException e){
e.printStackTrace();
}
}
}
package edu.eur.absa;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;

/**
* The Framework class sets up some application wide static variables and static methods that can be used
* throughout the framework
* @author Kim Schouten
*
*/
public class Framework {

/**
* Setting up some paths for the framework to use
*/
public static final String PATH = System.getProperty("user.dir")+"/";
public static final String RESOURCES_PATH = PATH+"src/main/resources/";
public static final String OUTPUT_PATH = PATH + "output/";
public static final String DATA_PATH = RESOURCES_PATH + "data/";
public static final String EXTERNALDATA_PATH = RESOURCES_PATH + "externalData/";
public static final String RAWDATA_PATH = RESOURCES_PATH + "data/raw/";
public static final String LIB_PATH = RESOURCES_PATH + "lib/";

//Debug, error, and log can be used to pipe all system output through one place.
//If you every decide you need to send your output somewhere else, you can simply
//update these methods.

public static void debug(String message){
System.out.println(message);
}
public static void error(String message){
System.err.println(message);
}
public static void log(String message){
// Logger.getGlobal().info(message);
System.out.println(message);
}

/**
* Console output is saved to a file instead of just displayed below.
* The console box has a limited amount of text it can display, so if you have much data,
* it makes sense to save it to a file instead. This can also be helpful to keep track of your experiment.
*/
public static void fileInsteadOfConsole(){
try {
PrintStream out = new PrintStream(new FileOutputStream(new File(OUTPUT_PATH + System.currentTimeMillis() + "_console.txt")));
System.setOut(out);

} catch (IOException e){
e.printStackTrace();
}
}

public static void supressJenaMessages() {
Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.INFO);
}
}
Expand Up @@ -41,9 +41,11 @@ public class SemEval2015Task12ABSAReader implements IDataReader {
* @throws Exception
*/
public static void main(String[] args) throws Exception{
showStatistics((new DatasetJSONReader()).read(new File(Framework.DATA_PATH+"SemEval2016SB1Laptops-Train.json")));

showStatistics((new DatasetJSONReader()).read(new File(Framework.DATA_PATH+"SemEval2016SB1Laptops-Test.json")));
processAllData();

// showStatistics((new DatasetJSONReader()).read(new File(Framework.DATA_PATH+"SemEval2016SB1Laptops-Train.json")));
//
// showStatistics((new DatasetJSONReader()).read(new File(Framework.DATA_PATH+"SemEval2016SB1Laptops-Test.json")));

}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/edu/eur/absa/model/Span.java
Expand Up @@ -325,12 +325,13 @@ public void clear() {
@Override
public boolean contains(Object o) {
if (o instanceof Word){
//TODO: This is extremely strange: without the cloning, a Word is not always properly found!
return ((TreeSet<Word>)words.clone()).contains((Word)o);
// //TODO: This is extremely strange: without the cloning, a Word is not always properly found!
return ( words.contains((Word)o) || ((TreeSet<Word>)words.clone()).contains((Word)o));
} else {
Framework.log("Incorrect comparison");
return false;
}
//return words.contains(o);
}

@Override
Expand Down

0 comments on commit a97f035

Please sign in to comment.