keep alpha source states during node propagation
[IRC.git] / Robust / src / Benchmarks / mlp / tagger / mlp-smaller / StandardEngine.java
diff --git a/Robust/src/Benchmarks/mlp/tagger/mlp-smaller/StandardEngine.java b/Robust/src/Benchmarks/mlp/tagger/mlp-smaller/StandardEngine.java
new file mode 100644 (file)
index 0000000..5f4059e
--- /dev/null
@@ -0,0 +1,209 @@
+/**\r
+ * StandardEngine class\r
+ * Standard registration of actions\r
+ * Implemented as a subclass of Engine for no good reason\r
+ *\r
+ * @author  Daniel Jackson\r
+ * @version 0, 07/08/01\r
+ */\r
+\r
+//package tagger;\r
+//import java.io.*;\r
+//import java.util.*;\r
+\r
+\r
+// a hack to work around lack of proper closures in Java\r
+// can't assign to local variable within actions\r
+class StringBox {\r
+  String string;\r
+  StringBox (String s) {string = s;}\r
+  void set (String s) {string = s;}\r
+}\r
+\r
+\r
+public class StandardEngine extends Engine {\r
+\r
+  //static Engine STANDARD;\r
+\r
+  // reserved words for property files\r
+\r
+  // character table\r
+  static public String index_prop_name           () { return "index";         }\r
+  static public String font_prop_name            () { return "font";         }\r
+                                                                             \r
+  static public String apostrophe_char_name      () { return "quoteright";    }\r
+  static public String prime_char_name           () { return "prime";        }\r
+  static public String opensinglequote_char_name () { return "quoteleft";     }\r
+  static public String closesinglequote_char_name() { return "quoteright";    }\r
+  static public String opendoublequote_char_name () { return "quotedblleft";  }\r
+  static public String closedoublequote_char_name() { return "quotedblright"; }\r
+  static public String hyphen_char_name          () { return "hyphen";       }\r
+  static public String endash_char_name          () { return "endash";       }\r
+  static public String emdash_char_name          () { return "emdash";       }\r
+  static public String period_char_name          () { return "period";       }\r
+  static public String twodotleader_char_name    () { return "twodotleader";  }\r
+  static public String ellipsis_char_name        () { return "ellipsis";      }\r
+                                                                             \r
+  static public String ROMAN_COMMANDNAME         () { return "roman";        }\r
+  static public String BOLD_COMMANDNAME          () { return "bold";         }\r
+  static public String ITALICS_COMMANDNAME       () { return "italic";       }\r
+  static public String SUBSCRIPT_COMMANDNAME     () { return "sub";          }\r
+  static public String SUPERSCRIPT_COMMANDNAME   () { return "sup";          }\r
+                                                                             \r
+  // style sheet                                                             \r
+  static public String next_style_prop_name      () { return "next";         }\r
+  static public String default_style_name        () { return "body";          }\r
+\r
+  \r
+  public StandardEngine (\r
+                        final Generator generator,\r
+                        final PropertyMap style_map,\r
+                        final FileOutputStream index_stream\r
+                        ) {\r
+    Engine();\r
+    \r
+    final PropertyMap char_map = new PropertyMap ();\r
+    final Numbering numbering = new Numbering (style_map);\r
+    \r
+    final StringBox current_para_style = new StringBox (default_style_name());\r
+\r
+    // special action for start of paragraph\r
+    // created once, but dynamically inserted and removed\r
+    // so that it's performed once at the start of each paragraph\r
+    final Action paragraph_action = new ParagraphAction ( generator,\r
+                                                         current_para_style,\r
+                                                         numbering );\r
+    \r
+    Action a = new PlaintextAction (generator);\r
+    register_by_type (a,\r
+                     Token.ALPHABETIC());\r
+    //register_by_type (a,\r
+    //       Token.NUMERIC());\r
+\r
+    /*\r
+    register_by_type (new PlaintextAction (generator),\r
+                     Token.NUMERIC());\r
+    \r
+    register_by_type (new PlaintextAction (generator),\r
+                     Token.WHITESPACE());\r
+    \r
+    register_by_type (new NewlineAction (generator),\r
+                     Token.LINEBREAK());\r
+    \r
+    register_by_type (new ApostropheAction (generator, char_map),\r
+                     Token.APOSTROPHE());\r
+    \r
+    register_by_type (new PrimeAction (generator, char_map),\r
+                     Token.PRIME());\r
+\r
+    register_by_type (new OpenSingleQuoteAction (generator, char_map),\r
+                     Token.OPENSINGLEQUOTE());\r
+    \r
+    register_by_type (new CloseSingleQuoteAction (generator, char_map),\r
+                     Token.CLOSESINGLEQUOTE());\r
+    \r
+    register_by_type (new OpenDoubleQuoteAction (generator, char_map),\r
+                     Token.OPENDOUBLEQUOTE());\r
+    \r
+    register_by_type (new CloseDoubleQuoteAction (generator, char_map),\r
+                     Token.CLOSEDOUBLEQUOTE());\r
+    \r
+    register_by_type (new HyphenAction (generator, char_map),\r
+                     Token.HYPHENS());\r
+    \r
+    register_by_type (new DotsAction (generator, char_map),\r
+                     Token.DOTS());\r
+    \r
+    register_by_type (new LoadCharMapCommandAction (generator,\r
+                                                   char_map,\r
+                                                   numbering),\r
+                     Token.LOADCHARMAPCOMMAND());\r
+    \r
+    register_by_type (new LoadStyleSheetCommandAction (generator,\r
+                                                      style_map,\r
+                                                      numbering),\r
+                     Token.LOADSTYLESHEETCOMMAND());\r
+    \r
+    final Action unsuppress_action = new UnsuppressAction (generator);\r
+    \r
+    // preamble command switches on output suppression\r
+    // registers action to turn suppression off with paragraph break command\r
+    register_by_type (new PreambleCommandAction (generator,\r
+                                                unsuppress_action,\r
+                                                this ),\r
+                     Token.PREAMBLECOMMAND());\r
+    \r
+    register_by_type (new ParaBreakAction (paragraph_action,\r
+                                          current_para_style,\r
+                                          style_map),\r
+                     Token.PARABREAK());\r
+    \r
+    register_by_type (new ParaStyleCommandAction (current_para_style),\r
+                     Token.PARASTYLECOMMAND());\r
+    \r
+    register_by_type (new CharCommandAction (generator,\r
+                                            char_map),\r
+                     Token.CHARCOMMAND());\r
+\r
+    register_by_type (new UnderscoreAction (generator) {},\r
+                     Token.UNDERSCORE());\r
+    \r
+    // used to italicize alphabetic tokens in math mode\r
+    final Action push_italics_action = new PushItalicsAction (generator);\r
+    final Action pop_italics_action = new PopItalicsAction (generator);\r
+    \r
+    register_by_type (new DollarAction (push_italics_action,\r
+                                       pop_italics_action),\r
+                     Token.DOLLAR());\r
+    \r
+    register_by_type (new FormatCommandAction (generator),\r
+                     Token.FORMATCOMMAND());\r
+    \r
+    register_by_type (new PopFormatCommandAction (generator),\r
+                     Token.POPFORMATCOMMAND());\r
+    \r
+    register_by_type (new OtherAction (generator),\r
+                     Token.OTHER());\r
+    \r
+    register_by_type (new EndOfStreamAction (generator),\r
+                     Token.ENDOFSTREAM());\r
+    \r
+    //STANDARD = this;\r
+    */\r
+  }\r
+\r
+\r
+  /* no actions for these token types:\r
+     COMMENT\r
+     SEPARATORCOMMAND\r
+  */\r
+  \r
+  /*\r
+    not yet coded:\r
+    \r
+    public static final int REFCOMMAND = 32;\r
+    public static final int TAGCOMMAND = 33;\r
+    public static final int CITECOMMAND = 34;\r
+  */\r
+  \r
+  \r
+  /* general form of action registration is this:\r
+     register_by_type (new Action () {\r
+     public void perform (Token t) {\r
+     // put code to be executed for token type here\r
+     }},\r
+     Token.TYPENAME);\r
+  */\r
+      \r
+  static public void put_special_char (Generator generator, \r
+                                      PropertyMap char_map,\r
+                                      String char_name,                \r
+                                      int line) {\r
+    String index = char_map.get_property (char_name, index_prop_name());\r
+    if (index == null) {\r
+      System.out.println (line + ": Unresolved character: " + char_name);\r
+    }\r
+    else\r
+      generator.special_char (index);\r
+  }\r
+}\r