Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made some modification to factory methods #252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ public class AQUAINT2Preprocessor {
/** Directory of the AQUAINT corpus */
private static String dir;

public AQUAINT2Preprocessor() {
handleparagraphs();
}

public void handleparagraphs() {
// convert to 'trectext'
MsgPrinter.printStatusMsg("Converting to 'trectext' format:\n");
if (convertToTrectext())
MsgPrinter.printStatusMsg("Documents converted successfully.");
else {
MsgPrinter.printErrorMsg("Could not convert documents.");
System.exit(1);
}
}





/**
* Adds paragraph tags to documents of type 'multi', 'advis' and 'other'.
* Documents of type 'story' are usually already tagged.
Expand Down Expand Up @@ -214,42 +233,4 @@ private static boolean convertToTrectext() {

return true;
}

/**
* <p>Entry point of the program.</p>
*
* <p>Preprocesses the AQUAINT-2 corpus.</p>
*
* @param args argument 1: directory of the AQUAINT-2 corpus
*/
public static void main(String[] args) {
if (args.length < 1) {
MsgPrinter.printUsage("java AQUAINT2Preprocessor " +
"AQUAINT2_directory");
System.exit(1);
}
dir = args[0];

// enable output of status and error messages
MsgPrinter.enableStatusMsgs(true);
MsgPrinter.enableErrorMsgs(true);

// add paragraph tags if missing
MsgPrinter.printStatusMsg("Adding paragraph tags:\n");
if (addParagraphTags())
MsgPrinter.printStatusMsg("Paragraph tags added successfully.\n");
else {
MsgPrinter.printErrorMsg("Could not add paragraph tags.");
System.exit(1);
}

// convert to 'trectext'
MsgPrinter.printStatusMsg("Converting to 'trectext' format:\n");
if (convertToTrectext())
MsgPrinter.printStatusMsg("Documents converted successfully.");
else {
MsgPrinter.printErrorMsg("Could not convert documents.");
System.exit(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public class AQUAINTFactory {
public AQUAINTPreprocessTemplate getAQUAINTType(String type) {
if (args.length < 1) {
MsgPrinter.printUsage("java AQUAINTFactory " + "directory");
System.exit(1);
}
type = args[0];

// enable output of status and error messages
MsgPrinter.enableStatusMsgs(true);
MsgPrinter.enableErrorMsgs(true);

// add paragraph tags if missing
MsgPrinter.printStatusMsg("Adding paragraph tags...");
if (addParagraphTags())
MsgPrinter.printStatusMsg("Paragraph tags added successfully.");
else {
MsgPrinter.printErrorMsg("Could not add paragraph tags.");
System.exit(1);
}
if(type == null) {
return null;
} else if(type.equalsIgnoreCase("AQUAINTPreprocess")) {
return new AQUAINTPreprocess;
} else if(type.equalsIgnoreCase("AQUAINT2Preprocess")) {
return new AQUAINT2Preprocess;
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public class AQUAINTPreprocessor {
*
* @return true, iff the preprocessing was successful
*/

public AQUAINTPreprocessor() {
handleparagraphs();
}

public void handleparagraphs() {
// split paragraphs
MsgPrinter.printStatusMsg("Splitting paragraphs...");
if (splitParagraphs())
MsgPrinter.printStatusMsg("Paragraphs splitted successfully.");
else {
MsgPrinter.printErrorMsg("Could not split paragraphs.");
System.exit(1);
}
}

private static boolean addParagraphTags() {
File[] files = FileUtils.getFilesRec(dir);

Expand Down Expand Up @@ -162,41 +178,4 @@ private static boolean splitParagraphs() {

return true;
}

/**
* <p>Entry point of the program.</p>
*
* <p>Preprocesses the AQUAINT corpus.</p>
*
* @param args argument 1: directory of the AQUAINT corpus
*/
public static void main(String[] args) {
if (args.length < 1) {
MsgPrinter.printUsage("java AQUAINTPreprocessor AQUAINT_directory");
System.exit(1);
}
dir = args[0];

// enable output of status and error messages
MsgPrinter.enableStatusMsgs(true);
MsgPrinter.enableErrorMsgs(true);

// add paragraph tags if missing
MsgPrinter.printStatusMsg("Adding paragraph tags...");
if (addParagraphTags())
MsgPrinter.printStatusMsg("Paragraph tags added successfully.");
else {
MsgPrinter.printErrorMsg("Could not add paragraph tags.");
System.exit(1);
}

// split paragraphs
MsgPrinter.printStatusMsg("Splitting paragraphs...");
if (splitParagraphs())
MsgPrinter.printStatusMsg("Paragraphs splitted successfully.");
else {
MsgPrinter.printErrorMsg("Could not split paragraphs.");
System.exit(1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package info.ephyra.indexing;

public abstract class AQUAINTPreprocessorTemplate{
/** Directory of the AQUAINT corpus */
protected static String dir;

// Common Methods
public void preProcessing() {
// enable output of status and error messages
MsgPrinter.enableStatusMsgs(true);
MsgPrinter.enableErrorMsgs(true);

// add paragraph tags if missing
MsgPrinter.printStatusMsg("Adding paragraph tags...");
if (addParagraphTags())
MsgPrinter.printStatusMsg("Paragraph tags added successfully.");
else {
MsgPrinter.printErrorMsg("Could not add paragraph tags.");
System.exit(1);
}
}


@Override
protected abstract static boolean addParagraphTags();




}