Skip to content

Commit

Permalink
Revamp filter system and make less sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
wareya committed May 28, 2017
1 parent f6a1965 commit cdb06cc
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 258 deletions.
6 changes: 2 additions & 4 deletions src/ConsoleMain.java
Expand Up @@ -27,10 +27,9 @@ public static void main(String[] args)
{
println(out, "Usage: java -jar analyzer.jar <corpus.txt> (-[dswlpn] )*");
println(out, "\tcorpus.txt: must be in utf-8. cannot be named \"-h\" or \"--help\".");
println(out, "\t-d: disable number-word blacklist (1, 1, 一, 一月, 月曜, etc)");
println(out, "\t-d: disable user dictionary (userdict.csv)");
println(out, "\t-s: strip 〈〉 (but not their contents) and enable 《》 furigana culling (incl. contents) (operates at the code unit level, before parsing)");
println(out, "\t-w: disable 'only in dictionary' filter");
println(out, "\t-l: disable part-of-speech filter");
println(out, "\t-p: disable punctuation filter");
println(out, "\t-n: enable special blacklist (names and jargon from certain VNs)");
println(out, "\t-c: count lines and export index of the first line a term shows up in");
Expand All @@ -47,8 +46,7 @@ public static void main(String[] args)
String argument = arguments.removeFirst();
if(argument.equals("-p")) filter_punctuation_enabled = false;
if(argument.equals("-w")) filter_dictionary_enabled = false;
if(argument.equals("-l")) filter_type_enabled = false;
if(argument.equals("-d")) blacklist_enabled = false;
if(argument.equals("-d")) enable_userfilter = false;
if(argument.equals("-n")) special_blacklist_enabled = true;
if(argument.equals("-s")) skip_furigana_formatting = true;
if(argument.equals("-c")) enable_linecounter = true;
Expand Down
23 changes: 7 additions & 16 deletions src/GUIMain.java
Expand Up @@ -13,15 +13,13 @@
public class GUIMain extends Main {
private static Thread worker = null;

static private JCheckBox option_enable_blacklist;
static private JCheckBox option_enable_filter_dictionary;
static private JCheckBox option_enable_filter_type;
static private JCheckBox option_enable_filter_punctuation;
static private JCheckBox option_enable_special_blacklist;

static private JCheckBox option_strip_furigana;
static private JCheckBox option_enable_linecount;
static private JCheckBox option_enable_userdict;
static private JCheckBox option_enable_userfilter;

public static void main(String[] args)
{
Expand Down Expand Up @@ -53,11 +51,9 @@ public static void main(String[] args)
JTextField field_write = new JTextField("");

JLabel explanation3 = new JLabel("Filters:");
option_enable_blacklist = new JCheckBox("Disallow number terms (1, 1, 一, 一月, 月曜, 一つ etc)", true);
option_enable_filter_dictionary = new JCheckBox("Require term to be in dictionary", true);
option_enable_filter_type = new JCheckBox("Disallow particles/conjunctions/inflections/names/etc", true);
option_enable_filter_punctuation = new JCheckBox("Disallow punctuation", true);
option_enable_special_blacklist = new JCheckBox("Enable special blacklist (names from certain VNs)", false);
option_enable_userfilter = new JCheckBox("Load filters from userfilter.csv", true);

JLabel explanation4 = new JLabel("Other options:");
option_strip_furigana = new JCheckBox("Strip 《》 furigana (occurs before parsing) (also deletes 〈 and 〉)", false);
Expand Down Expand Up @@ -90,11 +86,8 @@ public static void main(String[] args)

run.addActionListener((a)->
{
blacklist_enabled = option_enable_blacklist.isSelected();
filter_dictionary_enabled = option_enable_filter_dictionary.isSelected();
filter_type_enabled = option_enable_filter_type.isSelected();
filter_punctuation_enabled = option_enable_filter_punctuation.isSelected();
special_blacklist_enabled = option_enable_special_blacklist.isSelected();

skip_furigana_formatting = option_strip_furigana.isSelected();
enable_linecounter = option_enable_linecount.isSelected();
Expand All @@ -116,8 +109,10 @@ public static void main(String[] args)
}
else
{
System.out.println("Not using user dictionary");
//System.out.println("Not using user dictionary");
}

enable_userfilter = option_enable_userfilter.isSelected();

if(worker != null && worker.isAlive()) return;
worker = new Thread(() ->
Expand Down Expand Up @@ -178,11 +173,9 @@ else if(length >= 0.0)
write.setBounds(5, row, 65, 20); field_write.setBounds(75, row, pane.getWidth()-75-10, 20); row += 25;

row += 3; row = adder.apply(explanation3, row); row += 3;
row = adder.apply(option_enable_blacklist, row);
row = adder.apply(option_enable_filter_dictionary, row);
row = adder.apply(option_enable_filter_type, row);
row = adder.apply(option_enable_filter_punctuation, row);
row = adder.apply(option_enable_special_blacklist, row);
row = adder.apply(option_enable_userfilter, row);

row += 3; row = adder.apply(explanation4, row); row += 3;
row = adder.apply(option_strip_furigana, row);
Expand All @@ -203,11 +196,9 @@ else if(length >= 0.0)
pane.add(field_input);
pane.add(field_write);

pane.add(option_enable_blacklist);
pane.add(option_enable_filter_dictionary);
pane.add(option_enable_filter_type);
pane.add(option_enable_filter_punctuation);
pane.add(option_enable_special_blacklist);
pane.add(option_enable_userfilter);

pane.add(option_strip_furigana);
pane.add(option_enable_linecount);
Expand Down

0 comments on commit cdb06cc

Please sign in to comment.