Commit 573a63ac authored by Tien's avatar Tien

Hot fix short text bug

parent f4acfdaf
...@@ -8,7 +8,7 @@ import java.io.FileReader; ...@@ -8,7 +8,7 @@ import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
/** /**
* @author * @author Nguyen Minh Tien minh-tien.nguyen@imag.fr
*/ */
public class ThresholdsSet extends HashMap<String, Double[]> { public class ThresholdsSet extends HashMap<String, Double[]> {
......
...@@ -46,7 +46,8 @@ public class TextProcessor { ...@@ -46,7 +46,8 @@ public class TextProcessor {
ArrayList<Text> text = new ArrayList<Text>(); ArrayList<Text> text = new ArrayList<Text>();
/** /**
* Process a File (pdf,xml) to create clean set of text (incase of need to split) * Process a File (pdf,xml) to create clean set of text (incase of need to
* split)
* *
* @param original file * @param original file
* @param listOfFile * @param listOfFile
...@@ -78,7 +79,7 @@ public class TextProcessor { ...@@ -78,7 +79,7 @@ public class TextProcessor {
content = a.xmlextract(original); content = a.xmlextract(original);
} }
//lets deal with long file over here //lets deal with long file over here
//split content and the index part by part //split content and the index part by part
if (content.length() < maxlength) { if (content.length() < maxlength) {
...@@ -112,11 +113,13 @@ public class TextProcessor { ...@@ -112,11 +113,13 @@ public class TextProcessor {
return text; return text;
} }
/**
* Read the index file if it is avaiable /**
* @param path to the index file * Read the index file if it is avaiable
* @return hashmap of indexs *
*/ * @param path to the index file
* @return hashmap of indexs
*/
private HashMap<String, Integer> readindexfile(String path) throws IOException { private HashMap<String, Integer> readindexfile(String path) throws IOException {
File index = new File(path); File index = new File(path);
BufferedReader br; BufferedReader br;
...@@ -153,8 +156,12 @@ public class TextProcessor { ...@@ -153,8 +156,12 @@ public class TextProcessor {
lower = upper; lower = upper;
upper = content.length(); upper = content.length();
if (content.substring(lower, upper).length() < maxlength / 3) {
part[i] = (content.substring(lower, upper)); part[i - 1] = part[i - 1] + content.substring(lower, upper);
part = Arrays.copyOf(part, part.length - 1);
} else {
part[i] = (content.substring(lower, upper));
}
} }
return part; return part;
} }
......
...@@ -81,9 +81,13 @@ public class SciDetect_Local { ...@@ -81,9 +81,13 @@ public class SciDetect_Local {
} }
/** /**
* This should be where all the components be called,
* It can be used as an interface for a stand alone SciDetect API library.
* @throws IOException * @throws IOException
*/ */
private void compute() throws IOException { public void compute(String[] args) throws IOException {
readconfig();
readargs(args);
if (testpath != null) { if (testpath != null) {
DateFormat dateFormat = new SimpleDateFormat("HH:mm dd.MM.yyyy"); DateFormat dateFormat = new SimpleDateFormat("HH:mm dd.MM.yyyy");
Date date = new Date(); Date date = new Date();
...@@ -147,14 +151,14 @@ public class SciDetect_Local { ...@@ -147,14 +151,14 @@ public class SciDetect_Local {
} }
/** /**
* To print usage (-h) * To print usage (-h).
*/ */
private static void printUsage() { private static void printUsage() {
System.out.println("***** Scigen & Co Checker \n"); System.out.println("***** Scigen & Co Checker \n");
System.out.println("To test all files in a directory <pathToFilesDirToTest>:"); System.out.println("To test all files in a directory <pathToFilesDirToTest>:");
System.out.println("java -jar ScigenChecker_local.jar -l <pathToLogFile> -c <pathToFilesDirToTest> \n"); System.out.println("java -jar SciDetect_local.jar -l <pathToLogFile> -c <pathToFilesDirToTest> \n");
System.out.println("To print usage:"); System.out.println("To print usage:");
System.out.println("java -jar ScigenChecker_local.jar -h \n"); System.out.println("java -jar SciDetect_local.jar -h \n");
System.out.println("***** \n"); System.out.println("***** \n");
} }
...@@ -171,9 +175,7 @@ public class SciDetect_Local { ...@@ -171,9 +175,7 @@ public class SciDetect_Local {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
SciDetect_Local a = new SciDetect_Local(); SciDetect_Local a = new SciDetect_Local();
a.readconfig(); a.compute(args);
a.readargs(args);
a.compute();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment