net.sf.jlinkgrammar

## Class Linkage

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

-     public class Linkage
      extends java.lang.Object

  The linkage routines are primarily used to walk linkages and retrieve information about the sentence. You must fist call dictionary_create, sentence,_create, sentence_parse, in that order. Then you can process links.
  See Also:
    `Linkage(int, Sentence, ParseOptions)`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) static class` | `Linkage.LinkageAndList`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Linkage.LinkageAndList[]` | `andlist`
    `int` | `current` Allows user to select particular sublinkage
    `LinkageInfo` | `info` index and cost information
    `int` | `num_sublinkages` One for thin linkages, bigger for fat
    `ParseOptions` | `opts`
    `static char[][]` | `picture`
    `Sentence` | `sent`
    `Sublinkage[]` | `sublinkage` A parse with conjunctions will have several
    `boolean` | `unionized` if true, union of links has been computed
    `java.util.ArrayList<java.lang.String>` | `word` array of word spellings
    `static int[]` | `wordtype`
    `static char[][]` | `xpicture`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Linkage(int k, Sentence sent, ParseOptions opts)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `adjust_subordinate_clauses(int numcon_total, int numcon_subl)`
    `java.lang.String` | `build_linkage_postscript_string()` builds a postscript printable string of the current sublinkage
    `(package private) void` | `compute_chosen_words(Sentence sent)`
    `void` | `extract_fat_linkage(Sentence sent, ParseOptions opts)` The old C comment said -- This procedure mimics analyze_fat_linkage in order to extract the sublinkages and copy them to the Linkage data structure passed in.
    `(package private) static void` | `extract_links(int index, int cost, ParseInfo pi)` Generate the list of all links of the indexth parsing of the sentence.
    `(package private) void` | `extract_thin_linkage(Sentence sent, ParseOptions opts)` extract thin links from a sentence
    `java.lang.String` | `header(int mode)` Supplies the postscript header used when generating a postscript output file
    `(package private) boolean` | `link_already_appears(Link link, int a)`
    `int` | `linkage_and_cost()`
    `int` | `linkage_compute_union()` computes the union of the current sublinkages.
    `CNode` | `linkage_constituent_tree()` CNode linkage_constituent_tree(); The other useful method for dealing with a cosntituent tree is: String linkage_print_constituent_tree(int mode);
    `int` | `linkage_disjunct_cost()`
    `java.lang.String[]` | `linkage_get_link_domain_names(int index)`
    `java.lang.String` | `linkage_get_link_label(int index)`
    `java.lang.String` | `linkage_get_link_llabel(int index)`
    `int` | `linkage_get_link_lword(int index)`
    `int` | `linkage_get_link_num_domains(int index)`
    `java.lang.String` | `linkage_get_link_rlabel(int index)`
    `int` | `linkage_get_link_rword(int index)`
    `int` | `linkage_get_num_links()` This is need to set up the for loop to walk down a set of links for printing or other processing returns the size of the linkage array as the number of links
    `int` | `linkage_get_num_sublinkages()` This is a toplevel routine used to setup a for loop to process each sublinkage (usually an AND disjunct).
    `int` | `linkage_get_num_words()` Gives the number or word spellings or individual word spellings for the current sublinkage
    `Sentence` | `linkage_get_sentence()` getter for the sentence from an instantiated linkage
    `java.lang.String` | `linkage_get_violation_name()`
    `java.lang.String` | `linkage_get_word(int w)`
    `boolean` | `linkage_has_inconsistent_domains()`
    `boolean` | `linkage_is_canonical()`
    `boolean` | `linkage_is_improper()`
    `int` | `linkage_link_cost()`
    `void` | `linkage_post_process(Postprocessor postprocessor)` post process the sublinkages according to the named postprocessor
    `java.lang.String` | `linkage_print_constituent_tree(int mode)` String linkage_print_constituent_tree(int mode)
    `java.lang.String` | `linkage_print_diagram()`
    `java.lang.String` | `linkage_print_links_and_domains()`
    `java.lang.String` | `linkage_print_postscript(int mode)` Print out a postscript version of the constituent tree
    `boolean` | `linkage_set_current_sublinkage(int index)` setter function to set the current sublinkage to indicated index TODO - does this function have to insure a compact array? If so should it return the next available index?
    `int` | `linkage_unused_word_cost()`
    `(package private) boolean` | `links_are_equal(Link l, Link m)`
    `CNode` | `parse_string(CNode n, java.util.StringTokenizer tok)`
    `void` | `print_a_link(java.lang.StringBuffer s, int link)` Prints the information contained in a link into a supplied string buffer.
    `void` | `process_linkage(ParseOptions opts)`
    `void` | `set_centers(boolean print_word_0)`
    `void` | `setParseOptions(ParseOptions opts)` setter for object's copy of the ParseOptions
    `void` | `setSentence(Sentence sent)` setter for object's copy of the sentence
    `(package private) int` | `token_type(java.lang.String token)`
    `java.lang.String` | `trailer(int mode)`
    `(package private) Sublinkage` | `unionize_linkage()`
    `static boolean` | `uppercompare(java.lang.String s, java.lang.String t)`

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

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

- - ### Field Detail

    - #### word

          public java.util.ArrayList<java.lang.String> word

      array of word spellings

    - #### info

          public LinkageInfo info

      index and cost information

    - #### num_sublinkages

          public int num_sublinkages

      One for thin linkages, bigger for fat

    - #### current

          public int current

      Allows user to select particular sublinkage

    - #### sublinkage

          public Sublinkage[] sublinkage

      A parse with conjunctions will have several

    - #### unionized

          public boolean unionized

      if true, union of links has been computed

    - #### sent

          public Sentence sent

    - #### opts

          public ParseOptions opts

    - #### andlist

          public static Linkage.LinkageAndList[] andlist

    - #### wordtype

          public static int[] wordtype

    - #### picture

          public static char[][] picture

    - #### xpicture

          public static char[][] xpicture

  - ### Constructor Detail

    - #### Linkage

          public Linkage(int k,
                 Sentence sent,
                 ParseOptions opts)

  - ### Method Detail

    - #### setSentence

          public void setSentence(Sentence sent)

      setter for object's copy of the sentence
      Parameters:
        `sent` -

    - #### setParseOptions

          public void setParseOptions(ParseOptions opts)

      setter for object's copy of the ParseOptions
      Parameters:
        `opts` -

    - #### compute_chosen_words

          void compute_chosen_words(Sentence sent)

    - #### extract_links

          static void extract_links(int index,
                           int cost,
                           ParseInfo pi)

      Generate the list of all links of the indexth parsing of the sentence. For this to work, you must have already called parse, and already built the whole_set.

    - #### extract_thin_linkage

          void extract_thin_linkage(Sentence sent,
                                  ParseOptions opts)

      extract thin links from a sentence
      Parameters:
        `sent` - sentence to extract links from. TODO - does not set the current Linkage objects this.sent to sent. This may be a bug!
        `opts` - options to use when processing TODO - does not set the current Linkage objects this.opts to opts. This may be a bug!

    - #### extract_fat_linkage

          public void extract_fat_linkage(Sentence sent,
                                 ParseOptions opts)

      The old C comment said -- This procedure mimics analyze_fat_linkage in order to extract the sublinkages and copy them to the Linkage data structure passed in. BUT no linkage structure is passed in the Linkage structure is the instance variable of this Linkage.
      Parameters:
        `sent` - sentence to extract links from. TODO - does not set the current Linkage objects this.sent to sent. This may be a bug!
        `opts` - options to use when processing TODO - does not set the current Linkage objects this.opts to opts. This may be a bug!

    - #### linkage_unused_word_cost

          public int linkage_unused_word_cost()

      Returns:
        an integer value of the unused word cost

    - #### linkage_disjunct_cost

          public int linkage_disjunct_cost()

      Returns:
        an integer value of the disjunct cost

    - #### linkage_and_cost

          public int linkage_and_cost()

      Returns:
        the cos of And's

    - #### linkage_link_cost

          public int linkage_link_cost()

      Returns:
        the link cost

    - #### linkage_get_num_sublinkages

          public int linkage_get_num_sublinkages()

      This is a toplevel routine used to setup a for loop to process each sublinkage (usually an AND disjunct).
      Returns:
        the number of sublinkages

    - #### linkage_get_num_words

          public int linkage_get_num_words()

      Gives the number or word spellings or individual word spellings for the current sublinkage
      Returns:
        integer number of spellings

    - #### linkage_get_num_links

          public int linkage_get_num_links()

      This is need to set up the for loop to walk down a set of links for printing or other processing returns the size of the linkage array as the number of links
      Returns:
        the size of the linkage array as the number of links

    - #### linkage_set_current_sublinkage

          public boolean linkage_set_current_sublinkage(int index)

      setter function to set the current sublinkage to indicated index TODO - does this function have to insure a compact array? If so should it return the next available index?
      Returns:
        false if the likage index is already in use, true otherwise

    - #### linkage_get_sentence

          public Sentence linkage_get_sentence()

      getter for the sentence from an instantiated linkage
      Returns:
        the Sentence instance object held in this Linkage instance object

    - #### links_are_equal

          boolean links_are_equal(Link l,
                                Link m)

    - #### link_already_appears

          boolean link_already_appears(Link link,
                                     int a)

    - #### unionize_linkage

          Sublinkage unionize_linkage()

    - #### linkage_compute_union

          public int linkage_compute_union()

      computes the union of the current sublinkages. Arcs may cross.
      Returns:
        the integer number of sublinkages

    - #### process_linkage

          public void process_linkage(ParseOptions opts)

    - #### linkage_get_word

          public java.lang.String linkage_get_word(int w)

    - #### linkage_get_link_label

          public java.lang.String linkage_get_link_label(int index)

    - #### linkage_get_link_llabel

          public java.lang.String linkage_get_link_llabel(int index)

    - #### linkage_get_link_rlabel

          public java.lang.String linkage_get_link_rlabel(int index)

    - #### linkage_get_link_rword

          public int linkage_get_link_rword(int index)

    - #### linkage_get_link_lword

          public int linkage_get_link_lword(int index)

    - #### linkage_get_link_num_domains

          public int linkage_get_link_num_domains(int index)

    - #### linkage_get_link_domain_names

          public java.lang.String[] linkage_get_link_domain_names(int index)

    - #### linkage_get_violation_name

          public java.lang.String linkage_get_violation_name()

    - #### linkage_is_canonical

          public boolean linkage_is_canonical()

    - #### linkage_is_improper

          public boolean linkage_is_improper()

    - #### linkage_has_inconsistent_domains

          public boolean linkage_has_inconsistent_domains()

    - #### linkage_print_links_and_domains

          public java.lang.String linkage_print_links_and_domains()

    - #### print_a_link

          public void print_a_link(java.lang.StringBuffer s,
                          int link)

      Prints the information contained in a link into a supplied string buffer.
      Parameters:
        `s` - Empty stringbuffer supplied by the caller shich the method will use
        `link` - the index of the link

    - #### build_linkage_postscript_string

          public java.lang.String build_linkage_postscript_string()

      builds a postscript printable string of the current sublinkage

    - #### set_centers

          public void set_centers(boolean print_word_0)

    - #### linkage_print_diagram

          public java.lang.String linkage_print_diagram()

    - #### linkage_print_constituent_tree

          public java.lang.String linkage_print_constituent_tree(int mode)

      String linkage_print_constituent_tree(int mode)
      Parameters:
        `mode` - mode 1: treebank-style constituent tree mode 2: flat, bracketed tree [A like [B this B] A] mode 3: flat, treebank-style tree (A like (B this) )
      Returns:
        Returns the constituent tree in one of three modes, treebank, flat bracketed, or flat treebank

    - #### token_type

          int token_type(java.lang.String token)

    - #### parse_string

          public CNode parse_string(CNode n,
                           java.util.StringTokenizer tok)

    - #### linkage_constituent_tree

          public CNode linkage_constituent_tree()

      CNode linkage_constituent_tree(); The other useful method for dealing with a cosntituent tree is: String linkage_print_constituent_tree(int mode);
      Returns:
        A CNode is a standard tree data structure. The children of a node are stored as a linked list, with the end of the list indicated by next==NULL. The start and end fields of a node indicate the span of the constituent, with the first word indexed by 0. Leaves are defined by the condition child==NULL.

    - #### linkage_print_postscript

          public java.lang.String linkage_print_postscript(int mode)

      Print out a postscript version of the constituent tree
      Parameters:
        `mode` - mode 1: treebank-style constituent tree mode 2: flat, bracketed tree [A like [B this B] A] mode 3: flat, treebank-style tree (A like (B this) )
      Returns:
        A Java String version of a postscript file that can be sent to a print device.

    - #### adjust_subordinate_clauses

          public void adjust_subordinate_clauses(int numcon_total,
                                        int numcon_subl)

    - #### uppercompare

          public static boolean uppercompare(java.lang.String s,
                             java.lang.String t)

    - #### linkage_post_process

          public void linkage_post_process(Postprocessor postprocessor)

      post process the sublinkages according to the named postprocessor

    - #### trailer

          public java.lang.String trailer(int mode)

    - #### header

          public java.lang.String header(int mode)

      Supplies the postscript header used when generating a postscript output file
      Parameters:
        `mode` - Print out the constituent tree. mode 1: treebank-style constituent tree mode 2: flat, bracketed tree [A like [B this B] A] mode 3: flat, treebank-style tree (A like (B this) )
      Returns:
        Retunrs the String of the necessary postscript header.