net.sf.jlinkgrammar

## Class Postprocessor

- java.lang.Object
- - net.sf.jlinkgrammar.Postprocessor

-     public class Postprocessor
      extends java.lang.Object

  O.K. is this a static class? No it is used in the dictionary instance object which is then copied to the Sentence instance object, and then to the various Linkage instance objects. The programmmer will have to pay special attention to acertain wich postprocessor is used on any given linkage.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `Postprocessor.ApplyBounded`
    `(package private) static class` | `Postprocessor.ApplyConnected`
    `(package private) static class` | `Postprocessor.ApplyContainsNone`
    `(package private) static class` | `Postprocessor.ApplyContainsOne`
    `(package private) static class` | `Postprocessor.ApplyContainsOneGlobally`
    `(package private) static interface` | `Postprocessor.ApplyFn`
    `(package private) static class` | `Postprocessor.ApplyMustFormACycle`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) PPKnowledge` | `knowledge` internal rep'n of the actual rules
    `(package private) int` | `n_global_rules_firing` this is diagnostic
    `(package private) int` | `n_local_rules_firing` this is diagnostic
    `(package private) PPData` | `pp_data` root of the pp_data tree
    `(package private) PPNode` | `pp_node` root of the pp_node tree
    `(package private) int[]` | `relevant_contains_none_rules` a "-1" -terminated list of index
    `(package private) int[]` | `relevant_contains_one_rules` a "-1" -terminated list of index
    `(package private) PPLinkset` | `set_of_links_in_an_active_rule` used in *some* linkage of sentence
    `(package private) PPLinkset` | `set_of_links_of_sentence` seen in *any* linkage of sent
    `(package private) boolean[]` | `visited` maintain state during a call to post_process() for the depth-first search

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Postprocessor()` Constructor class placehoder for javadoc

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) static void` | `add_link_to_domain(Postprocessor pp, int link)` Add a link to the domain
    `(package private) static void` | `alloc_pp_node(Postprocessor pp)` set up a fresh pp_node for later use
    `(package private) static boolean` | `apply_relevant_rules(Postprocessor pp, Postprocessor.ApplyFn applyfn, Sublinkage sublinkage, PPRule[] rule_array, int[] relevant_rules, java.lang.String[] msg)` accumulate link names for this sentence, and need to apply all rules
    `(package private) static boolean` | `apply_rules(Postprocessor pp, Postprocessor.ApplyFn applyfn, Sublinkage sublinkage, PPRule[] rule_array, java.lang.String[] msg)`
    `(package private) static void` | `bad_depth_first_search(Postprocessor pp, Sublinkage sublinkage, int w, int root, int start_link)`
    `(package private) static void` | `build_domain_forest(Postprocessor pp, Sublinkage sublinkage)`
    `(package private) static void` | `build_domains(Postprocessor pp, Sublinkage sublinkage)` build the domains acociated with a sublinkage.
    `(package private) static void` | `build_type_array(Postprocessor pp)` Builds and array of domain types in the named post processor.
    `(package private) static void` | `connectivity_dfs(Postprocessor pp, Sublinkage sublinkage, int w, PPLinkset ls)`
    `(package private) static boolean` | `contained_in(Domain d1, Domain d2, Sublinkage sublinkage)` Used to determine if one domain is containd in another
    `(package private) static void` | `d_depth_first_search(Postprocessor pp, Sublinkage sublinkage, int w, int root, int right, int start_link)`
    `(package private) static void` | `depth_first_search(Postprocessor pp, Sublinkage sublinkage, int w, int root, int start_link)`
    `(package private) static int` | `find_domain_name(Postprocessor pp, java.lang.String link)` utility routines (not exported)
    `(package private) static void` | `free_pp_node(Postprocessor pp)`
    `(package private) static int` | `internal_process(Postprocessor pp, Sublinkage sublinkage, java.lang.String[] msg)` Walk the sublinkage and apply rules.
    `(package private) static boolean` | `is_connected(Postprocessor pp)` Returns true if the linkage is connected, considering words that have at least one edge....this allows conjunctive sentences not to be thrown out.
    `(package private) static void` | `left_depth_first_search(Postprocessor pp, Sublinkage sublinkage, int w, int right, int start_link)`
    `(package private) static boolean` | `link_in_domain(int link, Domain d)` determine if the given link is in the given domain
    `(package private) static void` | `mark_reachable_words(Postprocessor pp, int w)`
    `(package private) static void` | `post_process_close_sentence(Postprocessor pp)`
    `(package private) static void` | `post_process_free_data(PPData ppd)`
    `(package private) static boolean` | `post_process_match(java.lang.String s, java.lang.String t)` string comparison in postprocessing.
    `(package private) static void` | `reachable_without_dfs(Postprocessor pp, Sublinkage sublinkage, int a, int b, int w)` This is a depth first search of words reachable from w, excluding any direct edge between word a and word b.
    `(package private) static void` | `reset_pp_node(Postprocessor pp)`
    `(package private) static void` | `setup_domain_array(Postprocessor pp, int n, java.lang.String string, int start_link)`
    `(package private) static boolean` | `string_in_list(java.lang.String s, java.lang.String[] a)` returns false if the string s does not match anything in the array.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### knowledge

          PPKnowledge knowledge

      internal rep'n of the actual rules

    - #### n_global_rules_firing

          int n_global_rules_firing

      this is diagnostic

    - #### n_local_rules_firing

          int n_local_rules_firing

      this is diagnostic

    - #### set_of_links_of_sentence

          PPLinkset set_of_links_of_sentence

      seen in *any* linkage of sent

    - #### set_of_links_in_an_active_rule

          PPLinkset set_of_links_in_an_active_rule

      used in *some* linkage of sentence

    - #### relevant_contains_one_rules

          int[] relevant_contains_one_rules

      a "-1" -terminated list of index

    - #### relevant_contains_none_rules

          int[] relevant_contains_none_rules

      a "-1" -terminated list of index

    - #### visited

          boolean[] visited

      maintain state during a call to post_process() for the depth-first search

    - #### pp_node

          PPNode pp_node

      root of the pp_node tree
      See Also:
        `PPNode`

    - #### pp_data

          PPData pp_data

      root of the pp_data tree
      See Also:
        `PPData`

  - ### Constructor Detail

    - #### Postprocessor

          Postprocessor()

      Constructor class placehoder for javadoc

  - ### Method Detail

    - #### post_process_match

          static boolean post_process_match(java.lang.String s,
                                   java.lang.String t)

      string comparison in postprocessing. The first parameter is a post-processing symbol. The second one is a connector name from a link. The upper case parts must match. We imagine that the first arg is padded with an infinite sequence of "#" and that the 2nd one is padded with "*". "#" matches anything, but "*" is just like an ordinary char for matching purposes. For efficiency sake there are several different versions of these functions

    - #### post_process_close_sentence

          static void post_process_close_sentence(Postprocessor pp)

      Parameters:
        `pp` -

    - #### internal_process

          static int internal_process(Postprocessor pp,
                             Sublinkage sublinkage,
                             java.lang.String[] msg)

      Walk the sublinkage and apply rules. This helps determine if a linkage is valid
      Parameters:
        `pp` -
        `sublinkage` -
        `msg` -
      Returns:
        0 if the linakge satisfied all the rules
      See Also:
        `build_graph(Postprocessor, Sublinkage)`

    - #### string_in_list

          static boolean string_in_list(java.lang.String s,
                               java.lang.String[] a)

      returns false if the string s does not match anything in the array. The array elements are post-processing symbols
      Parameters:
        `s` -
        `a` -
      Returns:
        false if the string s does not match anything in the array

    - #### mark_reachable_words

          static void mark_reachable_words(Postprocessor pp,
                                  int w)

      Parameters:
        `pp` -
        `w` -

    - #### is_connected

          static boolean is_connected(Postprocessor pp)

      Returns true if the linkage is connected, considering words that have at least one edge....this allows conjunctive sentences not to be thrown out.
      Parameters:
        `pp` -
      Returns:
        true if the linkage is connected

    - #### build_domains

          static void build_domains(Postprocessor pp,
                           Sublinkage sublinkage)

      build the domains acociated with a sublinkage. TODO - Why does this pass in a PostProcessor object? How can this.pp_data ever be filled out if we don't copy it into this instance object?
      Parameters:
        `pp` -
        `sublinkage` -

    - #### build_domain_forest

          static void build_domain_forest(Postprocessor pp,
                                 Sublinkage sublinkage)

      Parameters:
        `pp` -
        `sublinkage` -

    - #### find_domain_name

          static int find_domain_name(Postprocessor pp,
                             java.lang.String link)

      utility routines (not exported)

    - #### contained_in

          static boolean contained_in(Domain d1,
                             Domain d2,
                             Sublinkage sublinkage)

      Used to determine if one domain is containd in another
      Parameters:
        `d1` -
        `d2` -
        `sublinkage` -
      Returns:
        returns true if domain d1 is contained in domain d2

    - #### link_in_domain

          static boolean link_in_domain(int link,
                               Domain d)

      determine if the given link is in the given domain
      Parameters:
        `link` -
        `d` -
      Returns:
        the predicate "the given link is in the given domain"

    - #### connectivity_dfs

          static void connectivity_dfs(Postprocessor pp,
                              Sublinkage sublinkage,
                              int w,
                              PPLinkset ls)

      Parameters:
        `pp` -
        `sublinkage` -
        `w` -
        `ls` -

    - #### add_link_to_domain

          static void add_link_to_domain(Postprocessor pp,
                                int link)

      Add a link to the domain
      Parameters:
        `pp` -
        `link` -

    - #### depth_first_search

          static void depth_first_search(Postprocessor pp,
                                Sublinkage sublinkage,
                                int w,
                                int root,
                                int start_link)

      Parameters:
        `pp` -
        `sublinkage` -
        `w` -
        `root` -
        `start_link` -

    - #### bad_depth_first_search

          static void bad_depth_first_search(Postprocessor pp,
                                    Sublinkage sublinkage,
                                    int w,
                                    int root,
                                    int start_link)

      Parameters:
        `pp` -
        `sublinkage` -
        `w` -
        `root` -
        `start_link` -

    - #### d_depth_first_search

          static void d_depth_first_search(Postprocessor pp,
                                  Sublinkage sublinkage,
                                  int w,
                                  int root,
                                  int right,
                                  int start_link)

      Parameters:
        `pp` -
        `sublinkage` -
        `w` -
        `root` -
        `right` -
        `start_link` -

    - #### left_depth_first_search

          static void left_depth_first_search(Postprocessor pp,
                                     Sublinkage sublinkage,
                                     int w,
                                     int right,
                                     int start_link)

      Parameters:
        `pp` -
        `sublinkage` -
        `w` -
        `right` -
        `start_link` -

    - #### setup_domain_array

          static void setup_domain_array(Postprocessor pp,
                                int n,
                                java.lang.String string,
                                int start_link)

      Parameters:
        `pp` -
        `n` -
        `string` -
        `start_link` -

    - #### reachable_without_dfs

          static void reachable_without_dfs(Postprocessor pp,
                                   Sublinkage sublinkage,
                                   int a,
                                   int b,
                                   int w)

      This is a depth first search of words reachable from w, excluding any direct edge between word a and word b.
      Parameters:
        `pp` -
        `sublinkage` -
        `a` -
        `b` -
        `w` -

    - #### apply_rules

          static boolean apply_rules(Postprocessor pp,
                            Postprocessor.ApplyFn applyfn,
                            Sublinkage sublinkage,
                            PPRule[] rule_array,
                            java.lang.String[] msg)

      Parameters:
        `pp` -
        `applyfn` -
        `sublinkage` -
        `rule_array` -
        `msg` -
      Returns:
        false if rule is violated

    - #### apply_relevant_rules

          static boolean apply_relevant_rules(Postprocessor pp,
                                     Postprocessor.ApplyFn applyfn,
                                     Sublinkage sublinkage,
                                     PPRule[] rule_array,
                                     int[] relevant_rules,
                                     java.lang.String[] msg)

      accumulate link names for this sentence, and need to apply all rules
      Parameters:
        `pp` -
        `applyfn` -
        `sublinkage` -
        `rule_array` -
        `relevant_rules` -
        `msg` -
      Returns:
        true if we need to apply all rules false of not

    - #### free_pp_node

          static void free_pp_node(Postprocessor pp)

      Parameters:
        `pp` -

    - #### alloc_pp_node

          static void alloc_pp_node(Postprocessor pp)

      set up a fresh pp_node for later use
      Parameters:
        `pp` -

    - #### reset_pp_node

          static void reset_pp_node(Postprocessor pp)

      Parameters:
        `pp` -

    - #### post_process_free_data

          static void post_process_free_data(PPData ppd)

      Parameters:
        `ppd` -

    - #### build_type_array

          static void build_type_array(Postprocessor pp)

      Builds and array of domain types in the named post processor.

      TODO - Should this reference this.pp_node.d_type_array? - jlr

      Parameters:
        `pp` -