LINK-PARSER(1)

πŸ“¦
version 5.13.0 Β· 2 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

okay bestie, so this is straight out of the General Commands Manual section, and it's the whole tea on link-parser, the command-line glow-up for the link-grammar library. grab a snack, we're parsing natural language πŸŽ€


✨ NAME ✨

link-parser β€” parse natural language sentences using Link Grammar


🌸 SYNOPSIS 🌸

link-parser --help
link-parser --version
link-parser [language|dict_location] [--quiet] [-<special_"!"_command>...]

πŸ¦‹ DESCRIPTION πŸ¦‹

link-parser is the command-line wrapper around the link-grammar natural language parsing library, and she's iconic for it πŸ’…

This library will parse sentences written in English, Russian and other languages, and it generates linkage trees that show the relationships between the subject, the verb, and all the various adjectives, adverbs, etc. hanging out in the sentence. it's giving sentence diagram but make it a graph, fr fr.


πŸ‘‘ EXAMPLE πŸ‘‘

link-parser

Starts the parser interactive shell. Enter any sentence to parse:

linkparser> Reading a man page is informative.

Found 18 linkages (18 had no P.P. violations)
        Linkage 1, cost vector = (UNUSED=0 DIS= 0.00 LEN=16)

    +------------------------Xp------------------------+
    +--------------->WV-------------->+                |
    |         +----------Ss*g---------+                |
    |         +--------Os-------+     |                |
    |         |     +---Ds**x---+     |                |
    +--->Wd---+     +-PHc+---A--+     +---Pa---+       |
    |         |     |    |      |     |        |       |
LEFT-WALL reading.g a man.ij page.n is.v informative.a .

look at her go. 18 linkages, zero P.P. violations, absolutely ate ✨


🧚 BACKGROUND 🧚

The link-parser command-line tool is useful for general exploration and use, although it is presumed that, for the parsing of large quantities of text, developers will create a custom application, making use of the link-grammar library. Several such applications are described on the Link Grammar web page (see SEE ALSO below πŸ‘€).

The theory of Link Grammar is explained in many academic papers. In the first of these, Daniel Sleator and Davy Temperley, "Parsing English with a Link Grammar" (1991), the authors defined a new formal grammatical system called a "link grammar". So here's the vibe check: a sequence of words is in the language of a link grammar if there is a way to draw "links" between words in such a way that

  • the local requirements of each word are satisfied,
  • the links do not cross, and
  • the words form a consistent connected graph.

The authors encoded English grammar into such a system, and wrote link-parser to parse English using this grammar. no cap.

The engine that performs the parsing is separate from the dictionaries describing a language. Currently, the most fully developed, complete dictionaries are for the English and Russian languages, although experimental, incomplete dictionaries exist for German and eight other languages. (yes, eight. we counted πŸ’œ)


🌈 OVERVIEW 🌈

link-parser, when invoked manually, starts an interactive shell, taking control of the terminal. Any lines beginning with an exclamation mark are assumed to be a "special command" β€” these are described below, bestie, stay tuned. The command !help will provide more info; the command !variables will print all of the special commands. These are also called "variables", because almost all commands have a value associated with them: the command typically enables or disables some function, or it alters some multi-valued setting.

All other input is treated as a single, English-language sentence; it is parsed, and the result of the parse is printed. The variables control what is printed: by default, an ASCII-graphics linkage is printed, although post-script output is also possible. The printing of the constituent tree can also be enabled. Other output controls include the printing of disjuncts and complete link data. so many knobs to turn, and honestly? obsessed πŸŽ€

In order to analyze sentences, link-parser depends on a link-grammar dictionary. This contains lists of words and associated metadata about their grammatical properties. An English language dictionary is provided by default. If other language dictionaries are installed in the default search locations, these may be explicitly specified by means of a 2-letter ISO language code: so, for example:

link-parser de

will start the parser shell with the German dictionary. danke, bestie πŸ‡©πŸ‡ͺ

Alternately, the dictionary location can be specified explicitly with either an absolute or a relative file path; so, for example:

link-parser /usr/share/link-grammar/en

will run link-parser using the English dictionary located in the typical install directory. πŸ“

link-parser can also be used in a non-interactive mode ("batch mode") via the -batch option (a special command, see below): so, for example:

cat thesis.txt | link-parser -batch

will read lines from the file thesis.txt, processing each one as a complete sentence. For sentences that don't have a full parse, it will print

+++++ error N

(N is a number) to the standard output.

Alternately, an input file may be specified with the !file filename special command, described below.

⚠️ heads up: note that using "batch mode" disables the usual ASCII-graphics linkage printing. The input sentences also don't appear by default on stdout. These features may be re-enabled via special commands; special commands may be interspersed with the input. so if your output looks ✨stripped✨, that's why, it's not broken, it's just the vibe you picked πŸ’…

Instead of specifying -batch in the command-line, !batch can be specified in the said input file.

For more details, use !help batch in link-parser's interactive shell.


and bestie… there's more πŸ‘€ keep scrolling πŸ’–

✨ OPTIONS ✨

okay bestie, here's the command-line tea πŸ’…

  • --help β€” Prints the usage and then dips out. Exit stage left. ✌️
  • --version β€” Prints the program version and all the configuration details, then exits. Iconic little flex.
  • --quiet β€” Suppresses those version messages on startup, so it's giving silent-but-deadly. 🀫

πŸ’… Special ! commands πŸ’…

so these special ! commands are lowkey the main character. You can drop them as command-line options, OR you can use them inside the interactive shell itself β€” just prefix them with ! at the start of the line. And here's the slay part: you do NOT need to type the whole option name, only enough letters to make it unique. iykyk. ✨

When you're specifying one as a command-line option, the special command gets a - in front instead of a !. Same vibe, different punctuation.

Boolean variables? Just toggle them by giving the !varname, like !batch β€” no notes, periodt. But the other variables are pickier, bestie: they need an equals sign. So it's !varname=value, for example !width=100. 😌

  • The !help command prints general help. When you issue it from the interactive shell, it can take an argument β€” usually a special command. Very "let me look that up for you."
  • The !variables command prints out all of the current variable settings. Receipts. 🧾
  • The !file command reads input from its argument file. Heads up: !file is not a variable, so you literally cannot set it. But you can use it over and over again. Reusable queen. πŸ‘‘
  • The !exit command tells link-parser to exit. Say bye bestie. πŸ¦‹

And plot twist β€” the exclamation mark ! is also a special command all by itself, and it's used to inspect the dictionary entry for any given word (optionally terminated by a subscript). So if you're doing this from inside the interactive shell, you need two exclamation marks before the word. The wildcard character * can be specified as the last character of the word so you can find multiple matches. 🌈

Default values of the special commands below are shown in parenthesis. Most of them are the default ones of the link-grammar library. Boolean default values are shown as on (1) or off (0). No cap. πŸ’―


  • !bad (off) β€” Enable display of bad linkages. Let's see the mess. πŸ’€
  • !batch (off) β€” Enable batch mode.
  • !constituents (0) β€” Generate constituent output. Its value may be:
    • 0 β€” Disabled
    • 1 β€” Treebank-style constituent tree
    • 2 β€” Flat, bracketed tree [A like [B this B] A]
    • 3 β€” Flat, treebank-style tree (A like (B this))
  • !cost-max (2.7) β€” Largest cost to be considered.
  • !dialect (no value) β€” Use the specified (comma-separated) names. They modify the disjunct cost of dictionary words whose expressions contain symbolic cost specifications.
  • !disjuncts (off) β€” Display of disjuncts used.
  • !echo (off) β€” Echo input sentence.
  • !graphics (on) β€” Enable graphical display of linkage. For each linkage, the sentence is printed along with a graphical representation of its linkage above it. ✨

The following notations are used for words in the sentence:

  • [word] β€” A word with no linkage.
  • word[?].x β€” An unknown word whose POS category x has been found by the parser.
  • word[!] β€” An unknown word whose link-grammar dictionary entry has been assigned by a RegEx. (Use !morphology=1 to see the said dictionary entry.)
  • word[~] β€” There was an unknown word in this position, and it has got replaced, using a spell guess with this word, that is found in the link-grammar dictionary.
  • word[&] β€” This word is a part of an unknown word which has been found to consist of two or more words that are in the link-grammar dictionary.
  • word.POS β€” This word found in the dictionary as word.POS.
  • word.#CORRECTION β€” This word is probably a typo - got linked as an alternative word CORRECTION.
  • For dictionaries that support morphology (enable with !morphology=1):
    • word= β€” A prefix morpheme
    • =word β€” A suffix morpheme
    • word.= β€” A stem
  • !islands-ok (on) β€” Use null-linked islands.
  • !limit (1000) β€” Limit the maximum linkages processed.
  • !links (off) β€” Enable display of complete link data.
  • !null (on) β€” Allow null links.
  • !morphology (off) β€” Display word morphology. When a word matches a RegEx, show the matching dictionary entry.
  • !panic (on) β€” Use "panic mode" if a parse cannot be quickly found. The command !panic_variables prints the special variables that are used only in "panic mode".
  • !postscript (off) β€” Generate postscript output.
  • !short (16) β€” Maximum length of short links.
  • !spell (7) β€” If zero, no spell and run-on corrections of unknown words are performed. Else, use up to this many spell-guesses per unknown word. In that case, the number of run-on corrections (word split) of unknown words is not limited.
  • !timeout (30) β€” Abort parsing after this many seconds.
  • !use-sat (off) β€” Use Boolean SAT-based parser.
  • !verbosity (1) β€” Level of detail in output. Some useful values:
    • 0 β€” No prompt, minimal library messages
    • 1 β€” Normal verbosity
    • 2 β€” Show times of the parsing steps
    • 3 β€” Display some more information messages
    • 4 β€” Display data file search and locale setup
    • 5-9 β€” Tokenizer and parser debugging
    • 10-19 β€” Dictionary debugging
    • 101 β€” Print all the dictionary connectors, along with their length limit
  • !walls (off) β€” Display wall words.
  • !width (16381)() β€” The width of the display. When writing to a terminal, this value is set from its width.
  • !wordgraph (0) β€” Display the wordgraph (word-split graph).
    • 0 β€” Disabled
    • 1 β€” Default display
    • 2 β€” Display parent tokens as subgraphs
    • 3 β€” Use esoteric display flags as set by !test=wg:FLAGS

πŸ“ FILES πŸ“

The following files are per-language, when LL is the 2-letter ISO language code. 🌍

  • LL/4.0.dict β€” The Link Grammar dictionary.
  • LL/4.0.affix β€” Values of entities used in tokenization.
  • LL/4.0.regex β€” Regular expressions (see regex(7)) that are used to match tokens not found in the dictionary.
  • LL/4.0.dialect β€” Dialect component definitions.
  • LL/4.0.knowledge β€” Post-processing definitions.
  • LL/4.0.constituent-knowledge β€” Definitions for producing a constituent tree.
  • command-help-LL.txt or command-help-LL-CC.txt β€” Help text for the !help topic special "!" command. If several such files are provided, the desired one can be selected by e.g. the LANGUAGE environment variable if it is set to LL or LL-CC (default is en). Currently only command-help-en.txt is provided.

The directory search order for these files is:

  • ./
  • data/
  • ../
  • ../data/
  • A custom data directory, as set by the API call dictionary_set_data_dir().
  • Installation-depended system data directory (*)
* This location is displayed as DICTIONARY_DIR when the --version argument is provided to link-parser on the command line. On windows it may be relative to the location of the link-grammar library DLL; in that case the actual location is displayed as "System data directory" when link-parser is invoked with -verbosity=4.

πŸ‘€ SEE ALSO πŸ‘€

  • The link-generator command can be used to generate random sentences from a given dictionary. 🎲
  • Information on the link-grammar shared-library API and the link types used in the parse is available at the Link Grammar website.
  • Peer-reviewed papers explaining Link Grammar can be found at original CMU site.
  • The source code of link-parser and the link-grammar library is located at GitHub.
  • The mailing list for Link Grammar discussion is at link-grammar Google group.

πŸŽ€ AUTHOR πŸŽ€

link-parser and the link-grammar library were written by Daniel Sleator <sleator@cs.cmu.edu>, Davy Temperley <dtemp@theory.esm.rochester.edu>, and John Lafferty <lafferty@cs.cmu.edu>. Genius behavior honestly. 🧠✨

This manual page was written by Ken Bloom <kbloom@gmail.com> for the Debian project and updated by Linas Vepstas <linasvepstas@gmail.com>.


and that's the whole page bestie, we're done!! 🫢 this lil masterpiece is Version 5.9.0, dated 2021-03-30, and it lives in the LINK-PARSER(1) section of the manual. go forth and parse, you absolute icon πŸ’–πŸŒΈ