Commit fbbc5529 authored by Bruno López Trigo's avatar Bruno López Trigo

Commit de parser de Weka con: lector de ficheiro Weka, constructor de regras,...

Commit de parser de Weka con: lector de ficheiro Weka, constructor de regras, xerador XML e realización lingüística
parents
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="WekaParser-v1" default="default" basedir=".">
<description>Builds, tests, and runs the project WekaParser-v1.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="WekaParser-v1-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
#Fri, 23 Feb 2018 12:58:52 +0100
C\:\\Users\\brilemau\\Documents\\repos\\TFG-ExpliClas\\codigo\\WekaParser-v1=
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rule>
<antecedents>
<antecedent>
<attribute name="Strength">
<value>0.04</value>
<textValue>Session</textValue>
<maxValue>0.136</maxValue>
<minValue>0.035</minValue>
<properties>
<properties>
<valueTxt>Session</valueTxt>
<interval>
<leftValue>0.035</leftValue>
<rightValue>0.0525</rightValue>
</interval>
</properties>
<properties>
<valueTxt>Standar</valueTxt>
<interval>
<leftValue>0.0525</leftValue>
<rightValue>0.0675</rightValue>
</interval>
</properties>
<properties>
<valueTxt>High</valueTxt>
<interval>
<leftValue>0.0675</leftValue>
<rightValue>0.09</rightValue>
</interval>
</properties>
<properties>
<valueTxt>Very high</valueTxt>
<interval>
<leftValue>0.09</leftValue>
<rightValue>0.136</rightValue>
</interval>
</properties>
</properties>
</attribute>
<interval>
<leftValue>0.035</leftValue>
<rightValue>0.07</rightValue>
</interval>
</antecedent>
<antecedent>
<attribute name="Color">
<value>20.0</value>
<textValue>Brown</textValue>
<maxValue>45.0</maxValue>
<minValue>0.0</minValue>
<properties>
<properties>
<valueTxt>Pale</valueTxt>
<interval>
<leftValue>0.0</leftValue>
<rightValue>3.0</rightValue>
</interval>
</properties>
<properties>
<valueTxt>Straw</valueTxt>
<interval>
<leftValue>3.0</leftValue>
<rightValue>7.5</rightValue>
</interval>
</properties>
<properties>
<valueTxt>Amber</valueTxt>
<interval>
<leftValue>7.5</leftValue>
<rightValue>19.0</rightValue>
</interval>
</properties>
<properties>
<valueTxt>Brown</valueTxt>
<interval>
<leftValue>19.0</leftValue>
<rightValue>29.0</rightValue>
</interval>
</properties>
<properties>
<valueTxt>Black</valueTxt>
<interval>
<leftValue>29.0</leftValue>
<rightValue>45.0</rightValue>
</interval>
</properties>
</properties>
</attribute>
<interval>
<leftValue>17.0</leftValue>
<rightValue>29.0</rightValue>
</interval>
</antecedent>
</antecedents>
<consequent>
<code>7.0</code>
<text>7.0</text>
</consequent>
</rule>
========================
BUILD OUTPUT DESCRIPTION
========================
When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).
To run the project from the command line, go to the dist folder and
type the following:
java -jar "WekaParser-v1.jar"
To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.
Notes:
* If two JAR files on the project classpath have the same name, only the first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, these files (folders)
are not copied.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.
libs.CopyLibs.classpath=\
${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
libs.CopyLibs.displayName=CopyLibs Task
libs.CopyLibs.prop-version=2.0
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
This diff is collapsed.
build.xml.data.CRC32=f50a7441
build.xml.script.CRC32=543316a7
build.xml.stylesheet.CRC32=8064a381@1.80.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=f50a7441
nbproject/build-impl.xml.script.CRC32=24a86cdd
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
application.args="C:\\Users\\brilemau\\Downloads\\ALL-infer.txt"
compile.on.save=true
do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=C:\\Users\\brilemau\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=WekaParser-v1
application.vendor=brilemau
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/WekaParser-v1.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.jaxb-api-2.2.jar=lib/jaxb-api-2.2.jar
file.reference.SimpleNLG-4.4.9-SNAPSHOT.jar=lib/SimpleNLG-4.4.9-SNAPSHOT.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.jaxb-api-2.2.jar}:\
${file.reference.SimpleNLG-4.4.9-SNAPSHOT.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
main.class=wekaparser.v1.WekaParserV1
# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
manifest.custom.application.library.allowable.codebase=
# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
manifest.custom.caller.allowable.codebase=
# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed
manifest.custom.codebase=
# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions)
manifest.custom.permissions=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>WekaParser-v1</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>.\lib\nblibraries.properties</definitions>
</libraries>
</configuration>
</project>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="Color">Pale,Straw,Amber,Brown,Black</entry>
<entry key="Color_Pale">0, 3</entry>
<entry key="Color_Straw">3, 7.5</entry>
<entry key="Color_Amber">7.5, 19</entry>
<entry key="Color_Brown">19, 29</entry>
<entry key="Color_Black">29, 45</entry>
<entry key="Bitterness">Low,Low-Medium,Medium-High,High</entry>
<entry key="Bitterness_Low">7, 21</entry>
<entry key="Bitterness_Low-Medium">21, 32.5</entry>
<entry key="Bitterness_Medium-High">32.5, 47.5</entry>
<entry key="Bitterness_High">47.5, 250</entry>
<entry key="Strength">Session,Standar,High,Very high</entry>
<entry key="Strength_Session">0.035, 0.0525</entry>
<entry key="Strength_Standar">0.0525, 0.0675</entry>
<entry key="Strength_High">0.0675, 0.09</entry>
<entry key="Strength_Very high">0.09, 0.136</entry>
</properties>
\ No newline at end of file
package inputsystem;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
/* Clase que representa un atributo con:
- nombre: nombre que identifica al atributo
- value: valor numérico que toma el atributo
- textValue: interpretación textual del valor numérico
según el archivo de configuración
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Attribute {
@XmlAttribute
@XmlID
private final String name;
@XmlElement(name="value")
private float value;
@XmlElement(name="textValue")
private String textValue;
@XmlElement(name="maxValue")
private float maxValue;
@XmlElement(name="minValue")
private float minValue;
@XmlElementWrapper
@XmlElement(name="properties")
private ArrayList<Property> properties;
public Attribute() {
this.name = null;
}
public Attribute(String name){
this.name = name;
this.properties = new ArrayList<>();
}
public Attribute(String name, float value, String textValue) {
this.name = name;
this.value = value;
this.textValue = textValue;
this.properties = new ArrayList<>();
}
public String getName() {
return name;
}
public float getValue() {
return value;
}
public float getMaxValue() {
return maxValue;
}
public float getMinValue() {
return minValue;
}
public void setValue(float value) {
this.value = value;
}
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public void setMaxValue(float maxValue) {
this.maxValue = maxValue;
}
public void setMinValue(float minValue) {
this.minValue = minValue;
}
public ArrayList<Property> getProperties() {
return properties;
}
public void addProperty(Property prop){
this.properties.add(prop);
}
}
package inputsystem;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import wekaparser.v1.SpecificObject;
public class InputSystem implements InputSystemInterface {
private final Reader reader;
public InputSystem(File file) throws FileNotFoundException {
this.reader = new Reader(file);
}
// Lectura de atributos posibles para la clasificación desde el archivo de Weka
@Override
public ArrayList<Attribute> readAttributes() {
ArrayList<Attribute> attributes = new ArrayList<>();
for(String att:this.reader.readAttributes())
attributes.add(new Attribute(att));
return attributes;
}
// Lectura de valores que el usuario proporciona a cada atributo
@Override
public void readUserValues(SpecificObject object) {
this.reader.readUserValues(object);
this.reader.closeReader();
}
}
package inputsystem;
import java.util.ArrayList;
import wekaparser.v1.SpecificObject;
public interface InputSystemInterface {
public ArrayList<Attribute> readAttributes();
public void readUserValues(SpecificObject object);
}
package inputsystem;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import rulesystem.Interval;
public class PropertiesReader {
// Asigna el valor textual al atributo en función del archivo de configuración
public void getAttributeProperty(Attribute attribute){
try {
// Abrir archivo properties
Properties prop = new Properties();
prop.loadFromXML(new FileInputStream("./resources/config.properties"));
String[] properties;
// Leer propiedades de atributo concreto (Color, Bitternes, Strength)
properties = prop.getProperty(attribute.getName()).split(",");
int lenght = properties.length;
int initial = lenght-1;
String[] values;
float left_value;
float right_value;
Property property;
// Para cada propiedad consultar intervalo
for(String s: properties){
lenght--;
values = prop.getProperty(attribute.getName() + "_" + s).split("(,\\s?)");
left_value = Float.parseFloat(values[0]);
right_value = Float.parseFloat(values[1]);
property = new Property(s, new Interval(left_value, right_value));
attribute.addProperty(property);
if(initial == lenght)
attribute.setMinValue(left_value);
else if(lenght == 0)
attribute.setMaxValue(right_value);
// Si el valor del atributo entra dentro del intervalo, entonces establecer la propiedad correspondiente
if(attribute.getValue()>=left_value && attribute.getValue()<right_value){
attribute.setTextValue(s);
}
// Caso específico para el último intervalo donde se debe tomar el valor derecho
else if(lenght == 0 && attribute.getValue()>=left_value && attribute.getValue()<=right_value){
attribute.setTextValue(s);
}
}
} catch (FileNotFoundException ex) {
Logger.getLogger(PropertiesReader.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(PropertiesReader.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
package inputsystem;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import rulesystem.Interval;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Property {
@XmlElement(name="valueTxt")
private final String valueTxt;
@XmlElement(name="interval")
private final Interval interval;
public Property() {
this.valueTxt = null;
this.interval = null;
}
public Property(String valueTxt, Interval interval) {
this.valueTxt = valueTxt;
this.interval = interval;
}
public Interval getInterval() {
return interval;
}
public String getValueTxt() {
return valueTxt;