Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents c345d7b + ba3f1f6 commit c00f286ac06a3db7dbb9fcb29c83daf7713d355f @xearax committed Feb 1, 2012
Showing with 20 additions and 6 deletions.
  1. +6 −3 src/logic.java
  2. +9 −3 src/main.java
  3. +1 −0 src/preprocess.java
  4. +4 −0 src/verdict.java
View
@@ -4,10 +4,12 @@
public class logic {
private Vector<verdict> classificationResult;
private File path;
+ private String modelPath;
- public logic( String inPath ) {
+ public logic( String inPath, String inModelPath ) {
path = new File( inPath );
classificationResult = new Vector<verdict>();
+ modelPath = inModelPath;
}
public int start() {
@@ -39,14 +41,15 @@ private void traverse( File inPath ) {
} else if ( inPath.isFile() ) {
if ( isFileOK( inPath ) ) {
extractor Xtractor = new extractor( inPath.getAbsolutePath() );
- preprocess pprocess = new preprocess( Xtractor.getLicense() );
+ String tmp = Xtractor.getLicense();
+ preprocess pprocess = new preprocess( tmp );
if ( pprocess.start() != 0 ) {
misc.log( "Error: preprocess failed for file: " + inPath.getAbsolutePath() );
System.exit( 1 );
}
- classifier cfier = new classifier( "/some/where/classifier.model", pprocess.getInstances() );
+ classifier cfier = new classifier( modelPath, pprocess.getInstances() );
cfier.start();
classificationResult.add( new verdict( inPath.getAbsolutePath(), cfier.getVerdict() ) );
}
View
@@ -3,6 +3,7 @@
public class main {
private static Vector<verdict> result;
+ private static String modelPath = "";
public static void main( String args[] ) {
@@ -16,7 +17,7 @@ public static void main( String args[] ) {
System.exit( 2 );
}
- logic alue = new logic( args[ 0 ] );
+ logic alue = new logic( args[ 0 ], modelPath );
alue.start();
result = alue.getVerdict();
@@ -29,14 +30,19 @@ private static int parse( String inArgs[] ) {
if ( inArgs.length > 0 )
if ( inArgs[ 0 ].length() > 0 )
return 0;
+ else if ( inArgs.length > 2 ) {
+ if ( inArgs[ 1 ].equalsIgnoreCase( "-c" ) ) {
+ modelPath = inArgs[ 2 ];
+ }
+ }
- System.err.println( "Usage: ./alue <path-to-eula-file-or-directory>" );
+ System.err.println( "Usage: ./alue <path-to-eula-file-or-directory> [-c <path-to-model-file>]" );
return 1;
}
private static int dependencies() {
- String dependencies[] = {"trid", "7zip", "unrtf" };
+ String dependencies[] = {"trid", "7z" };
int result = 0;
for ( int count=0; count < dependencies.length; count++ ) {
View
@@ -4,6 +4,7 @@
import weka.core.Instances;
import weka.filters.unsupervised.attribute.StringToWordVector;
import weka.core.stemmers.IteratedLovinsStemmer;
+import weka.core.stemmers.Stemmer;
import weka.core.tokenizers.CharacterDelimitedTokenizer;
import weka.core.tokenizers.Tokenizer;
import weka.core.tokenizers.WordTokenizer;
View
@@ -14,4 +14,8 @@ public String getName() {
public String getResult() {
return result;
}
+
+ public String toString() {
+ return "Result: " + result + " for '" + name + "'.";
+ }
}

0 comments on commit c00f286

Please sign in to comment.