Commit b3567788 authored by Tien's avatar Tien

added some java doc

parent bc5c8914
......@@ -16,12 +16,8 @@
*/
package fr.imag.forge.scidetect.Checker;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import fr.imag.forge.scidetect.Checker.Utils.DistancesSet;
......@@ -41,7 +37,6 @@ public class Classifier {
private ThresholdsSet SetOfThresholds;
/**
* @throws Exception
*
*/
public Classifier() {
......
......@@ -32,6 +32,12 @@ public class DistantCalculator {
//private HashMap<String, HashMap<String, Double>> distant = new HashMap<String, HashMap<String, Double>>();
private DistancesSet distant = new DistancesSet();
/**
*calculate the distant between 2 text corpus
* @param samples corpus
* @param tests corpus
* @return DistancesSet from test to sample
*/
public DistancesSet caldistant(Corpus samples, Corpus tests) {
for (String key : tests.keySet()) {
//HashMap<String, Double> distantto = new HashMap<String, Double>();
......@@ -47,7 +53,9 @@ public class DistantCalculator {
return distant;
}
/**
*Calculate distant between 2 text index
*/
private double cal_textdistant(HashMap<String, Integer> text1,
HashMap<String, Integer> text2) {
double nboftoken = 0.0;
......
......@@ -30,6 +30,8 @@ public class Indexer {
private Object content;
/**
* Index a text (count how many time each word appeared)
* and write to file under then name INDEX-filename.txt
* @param content
* @param textfile
* @throws FileNotFoundException
......
......@@ -16,9 +16,9 @@
*/
package fr.imag.forge.scidetect.Checker;
import com.sun.corba.se.spi.transport.CorbaAcceptor;
import fr.imag.forge.scidetect.TextExtractor.Xmlextractor;
import fr.imag.forge.scidetect.TextExtractor.pdfextractor;
//import com.sun.corba.se.spi.transport.CorbaAcceptor;
//import fr.imag.forge.scidetect.TextExtractor.Xmlextractor;
//import fr.imag.forge.scidetect.TextExtractor.pdfextractor;
import fr.imag.forge.scidetect.Corpus.Corpus;
import fr.imag.forge.scidetect.Corpus.ProcessText;
import fr.imag.forge.scidetect.Corpus.Text;
......@@ -26,13 +26,8 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
*
......@@ -47,6 +42,11 @@ public class Reader {
private String SamplesFolder;
private int maxlength;
/**
*Read config file
* @throws FileNotFoundException
* @throws IOException
*/
public void readconfig() throws FileNotFoundException, IOException {
File conf = new File("config.txt");
BufferedReader br = new BufferedReader(new FileReader(conf));
......@@ -69,6 +69,12 @@ public class Reader {
}
/**
*Read the sample folder
* @param foldername
* @return sample corpus
* @throws IOException
*/
public Corpus readsamples(String foldername) throws IOException {
File folder = new File(foldername);
File[] listOfFile = folder.listFiles();
......@@ -89,6 +95,12 @@ public class Reader {
}
/**
*Read the test folder
* @param foldername
* @return test corpus
* @throws IOException
*/
public Corpus readtests(String foldername) throws IOException {
File folder = new File(foldername);
File[] listOfFile = folder.listFiles();
......
......@@ -27,18 +27,35 @@ public class Corpus {
private HashMap<String, Text> corpus = new HashMap<String, Text>();
public void put(Text a) {
corpus.put(a.getname(), a);
/**
*set a new text into the corpus
* @param text
*/
public void put(Text text) {
corpus.put(text.getname(), text);
}
/**
*get the whole corpus
* @return corpus
*/
public HashMap<String, Text> getcorpus() {
return corpus;
}
/**
*get the set of key inside the corpus
* @return set of key
*/
public Set<String> keySet() {
return corpus.keySet();
}
/**
*get a specific index of a text inside the corpus
* @param name of the file
* @return index of the file
*/
public HashMap<String, Integer> get(String name) {
return corpus.get(name).getindex();
}
......
......@@ -39,14 +39,19 @@ import java.util.logging.Logger;
*/
public class ProcessText {
/**
*
*/
public static int maxlength;
ArrayList<Text> text = new ArrayList<Text>();
/**
* Process a File (pdf,xml) to create clean 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 listOfFile
* @return list of text[]
* @throws java.io.IOException
*
*/
public ArrayList<Text> newtext(File original, File[] listOfFile) throws IOException {
......@@ -107,7 +112,11 @@ public class ProcessText {
return text;
}
/**
* Read the index file if it is avaiable
* @param path to the index file
* @return hashmap of indexs
*/
private HashMap<String, Integer> readindexfile(String path) throws IOException {
File index = new File(path);
BufferedReader br;
......
......@@ -28,20 +28,36 @@ public class Text {
private String cleantext = "";
private String name = "";
/**
*set the index of the text
* @param a
*/
public void setindex(HashMap<String, Integer> a) {
index = a;
}
/**
*set the name of the text file
* @param a
*/
public void setname(String a) {
name = a;
}
/**
*get the index of the text
* @return index
*/
public HashMap<String, Integer> getindex() {
return index;
}
/**
*get the name of the text file
* @return name
*/
public String getname() {
return name;
}
......
......@@ -16,7 +16,6 @@
*/
package fr.imag.forge.scidetect.TextExtractor;
import static java.awt.SystemColor.text;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
......@@ -67,6 +66,7 @@ public class Xmlextractor {
* @param xml xml File
*
* @return extracted content
* @throws java.io.IOException
*/
public String xmlextract(File xml) throws IOException {
try {
......
......@@ -36,6 +36,7 @@ public class normalizer {
* @param txt the File to be cleaned and normalized the resulting text is overwrites the original text.
*
* @return contains all the normalized text.
* @throws java.io.IOException
*/
public String normalize(File txt) throws IOException {
BufferedReader br;
......
......@@ -37,6 +37,7 @@ public class pdfextractor {
* @param pdf a pdf File
*
* @return a string containing the extracted text.
* @throws java.io.IOException
*/
public String pdfextract(File pdf) throws IOException {
......
......@@ -18,11 +18,9 @@ package fr.imag.forge.scidetect.scigenchecker_local;
import fr.imag.forge.scidetect.Checker.Classifier;
import fr.imag.forge.scidetect.Checker.DistantCalculator;
import fr.imag.forge.scidetect.Checker.Indexer;
import fr.imag.forge.scidetect.Checker.Reader;
import fr.imag.forge.scidetect.Checker.Utils.DistancesSet;
import fr.imag.forge.scidetect.Logger.Log;
import fr.imag.forge.scidetect.TextExtractor.pdfextractor;
import fr.imag.forge.scidetect.Corpus.Corpus;
import java.io.BufferedReader;
......@@ -30,12 +28,9 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
/**
*
......@@ -171,6 +166,7 @@ public class ScigenChecker_Local {
* in the MyConf/checklog.txt:
* java -jar ScigenChecker_local.jar -l MyConf/checklog.txt -c MyConf/PDF/
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
......
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