### Running the Link Parser Executable Source: https://github.com/opencog/link-grammar/blob/master/mingw/README-Cygwin.md Examples of how to execute the link-parser command-line tool from different environments. This includes running it before and after installation, and from Windows cmd.exe. ```shell > PATH-TO-LG-CONF-DIRECTORY\link-parser\link-parser [arguments] ``` ```shell $ PATH-TO-LG-CONF-DIRECTORY/link-parser/link-parser [args] ``` ```shell $ link-parser [arguments] ``` -------------------------------- ### Makefile Example with Pkg-config Source: https://github.com/opencog/link-grammar/blob/master/README.md An example of how to integrate `pkg-config` flags into a Makefile for compiling C code that uses the Link Grammar library. It shows how to get flags for both compilation and linking. ```makefile .c.o: cc -O2 -g -Wall -c $< `pkg-config --cflags link-grammar` $(EXE): $(OBJS) cc -g -o $@ $^ `pkg-config --libs link-grammar` ``` -------------------------------- ### Compiling and Installing the Link Grammar System Source: https://github.com/opencog/link-grammar/blob/master/README.md Steps to compile the Link Grammar shared library and demonstration program, install it, and update the shared library cache. ```shell ./configure make make check ``` ```shell make install ldconfig ``` ```shell make installcheck ``` -------------------------------- ### Link-Parser Command Example Source: https://github.com/opencog/link-grammar/blob/master/diary/ru-benchmark.txt Example command for running the link-parser with specific parameters, including timeout and panic mode. ```bash link-parser parameters: [-u] -panic -timeout=10000 data/ru/4.0.batch ``` -------------------------------- ### Install Node.js Link Grammar Bindings Source: https://github.com/opencog/link-grammar/blob/master/README.md Steps to install and build the Node.js library bindings for Link Grammar using npm. Requires prior C library build. Creates library bindings and runs unit tests. ```shell cd bindings/node.js npm install npm run make ``` -------------------------------- ### Install link-parser Source: https://github.com/opencog/link-grammar/blob/master/bindings/js/link-parser/README.md Install the link-parser CLI globally for command-line use or as a project dependency using npm. ```shell npm install --global link-parser ``` ```shell npm install --save link-parser ``` -------------------------------- ### Build and Install Link Grammar Source: https://github.com/opencog/link-grammar/blob/master/mingw/README-Cygwin.md Commands to build and install the Link Grammar system using make. It specifies using a single process (-j 1) and disabling built-in rules (-r) for potentially faster compilation. ```shell $ make -r -j 1 $ make -r install ``` -------------------------------- ### Solver Configuration Examples (guiding.cpp) Source: https://github.com/opencog/link-grammar/blob/master/diary/ru-benchmark.txt Illustrates different configurations of solver parameters in guiding.cpp. Each block shows variations in setting decision variables, bumping activity, and polarity, with comments indicating which lines are active. ```cpp solver->setDecisionVar(v, _parameters[v].isDecision); solver->varBumpActivity(v, _parameters[v].priority); solver->setPolarity(v, _parameters[v].polarity > 0.0); ``` ```cpp solver->setDecisionVar(v, _parameters[v].isDecision); //B solver->varBumpActivity(v, _parameters[v].priority); //C solver->setPolarity(v, _parameters[v].polarity > 0.0); ``` ```cpp solver->setDecisionVar(v, _parameters[v].isDecision); // B solver->setPolarity(v, _parameters[v].polarity > 0.0); ``` ```cpp // A // B // C ``` -------------------------------- ### Python Bindings Installation Notes Source: https://github.com/opencog/link-grammar/blob/master/msvc/README.md Outlines the steps for installing Python bindings for the Link Grammar library. This includes copying specific `.py`, `__init__.py`, and `.pyd` files to a dedicated directory and setting the PYTHONPATH environment variable to include this directory. ```shell export PYTHONPATH=/path/to/linkgrammar/directory:$PYTHONPATH ``` -------------------------------- ### External Regex Package Setup Source: https://github.com/opencog/link-grammar/blob/master/msvc/LIBREGEX-README.md Configuration steps to integrate an optional external regex package. This involves adding library names, include directories, library directories, and DLL paths. ```APIDOC Setup Steps for External Regex Package: 1. **Additional Dependencies**: Add the library name to **Linker->Input->Additional Dependencies**. Example: `pcre2-8.lib`. Note: This is not defined by default and is crucial for the regex library to function. 2. **Regex Package Directory**: Define the directory of the optional regex package using the User Macro `GNUREGEX_DIR`. Default: `%HOMEDRIVE%%HOMEPATH%\Libraries\gnuregex`. 3. **Include Directories**: Add the directory of `regex.h` to **C/C++->General->Additional Include Directories**. Default: `$(GNUREGEX_DIR)\include`. 4. **Library Directories**: Add the library directory to **Linker->General->Additional Library Directories**. Default: `$(GNUREGEX_DIR)\lib`. 5. **DLL Path**: Unless the regex DLL directory is in your system `PATH`, set the User Macro `LG_DLLPATH`. Default: `$(GNUREGEX_DIR)\lib`. ``` -------------------------------- ### Install and Build Node.js Bindings Source: https://github.com/opencog/link-grammar/blob/master/bindings/node.js/README.md Installs the necessary dependencies and builds the Node.js bindings for the Link Grammar parser using npm commands. Ensure Link Grammar is built prior to executing these commands. ```bash npm install npm run make ``` -------------------------------- ### Running the Link Grammar Parser Source: https://github.com/opencog/link-grammar/blob/master/README.md This snippet shows the basic command to start the Link Grammar parser program. It accepts arguments for customization and can be controlled via internal commands like '!var' and '!help'. ```bash link-parser [arguments] ``` -------------------------------- ### Install Python Bindings to Custom Directory (macOS) Source: https://github.com/opencog/link-grammar/blob/master/README.md Command for macOS users to install Python bindings into a custom directory due to file permission settings. ```shell make install pythondir=/where/to/install ``` -------------------------------- ### Manually Set PYTHONPATH for Testing Source: https://github.com/opencog/link-grammar/blob/master/bindings/python-examples/README.md Illustrates how to manually set the `PYTHONPATH` environment variable to include the Link Grammar Python binding directories. This is necessary for running Python examples or tests without installing the bindings system-wide. ```shell PYTHONPATH=$SRC_DIR/bindings/python:$BUILD_DIR/bindings/python:$BUILD_DIR/bindings/python/.libs ``` -------------------------------- ### Manually Run Tests After Installation Source: https://github.com/opencog/link-grammar/blob/master/bindings/python-examples/README.md Explains how to manually test the installed Link Grammar Python bindings by setting the `PYTHONPATH` to the site-packages directory. This ensures the bindings are correctly recognized by the Python interpreter. ```shell PYTHONPATH=/usr/local/lib/python3.9/site-packages ``` -------------------------------- ### Link Grammar Parser Initialization (Shell) Source: https://github.com/opencog/link-grammar/blob/master/link-grammar/dict-atomese/README.md Demonstrates how to start the link-parser with a specific demo dictionary, such as 'demo-atomese'. This command loads the parser and associated linguistic data. ```shell link-parser demo-atomese ``` -------------------------------- ### Atomese Dictionary Example (Scheme) Source: https://github.com/opencog/link-grammar/blob/master/link-grammar/dict-atomese/README.md An example of an Atomese dictionary file written in Scheme. This file defines linguistic structures and vocabulary for the link-grammar parser. ```scheme ;; Example content of atomese-dict.scm ;; This file is a placeholder for actual Scheme code defining the dictionary. ;; It would typically contain definitions for words, grammatical rules, and semantic structures. ;; Example: Defining a simple word (define-word "bird" (lambda (w) (word-with-tag w 'noun))) ;; Example: Defining a simple sentence structure (define-sentence "Mary saw a bird" (lambda (s) (parse-sentence s))) ;; The actual file content would be more extensive and complex. ``` -------------------------------- ### Build Node.js Emscripten Link Grammar Wrapper Source: https://github.com/opencog/link-grammar/blob/master/README.md Steps to build the Emscripten wrapper for the Link Grammar command-line tool for Node.js. Includes installing the Emscripten SDK. ```shell cd bindings/js ./install_emsdk.sh ./build_packages.sh ``` -------------------------------- ### Link Grammar: Preposition Linking Example Source: https://github.com/opencog/link-grammar/blob/master/README.md An example demonstrating a parsing inadequacy in the link-grammar for sentences with conjoined prepositional phrases, specifically 'look at and listen to everything'. The goal is to link 'everything' to both prepositions correctly. ```APIDOC LinkGrammarParsing: PrepositionLinking: Sentence: "he wanted to look at and listen to everything." InadequateParse: Description: - The current parse is inadequate. - The link to 'everything' needs to connect to 'and'. - This ensures 'listen to' and 'look at' are treated as atomic verb phrases. Goal: Description: - To correctly link the object 'everything' to both prepositions ('at', 'to') via the conjunction 'and'. - Treat 'look at' and 'listen to' as coordinated verb phrases. ``` -------------------------------- ### Generic 'any' Language Example Source: https://github.com/opencog/link-grammar/blob/master/README.md Illustrates the Link Parser's handling of uniformly-sampled random planar graphs using the 'any' language setting. ```text linkparser> asdf qwer tyuiop fghj bbb Found 1162 linkages (1162 had no P.P. violations) +-------ANY------+-------ANY------+ +---ANY--+--ANY--+ +---ANY--+--ANY--+ | | | | | | LEFT-WALL asdf[!] qwer[!] tyuiop[!] fghj[!] bbb[!] ``` -------------------------------- ### Lua FFI Setup and Dependencies Source: https://github.com/opencog/link-grammar/blob/master/bindings/node.js/README.md Initializes the Lua environment by requiring necessary libraries like ffi, ref, ref-struct, and underscore for interacting with the native Link Grammar library and utility functions. ```lua ffi = require 'ffi' ref = require 'ref' Struct = require 'ref-struct' _ = require 'underscore' ``` -------------------------------- ### 'ady' Language Example with Morphological Splitting Source: https://github.com/opencog/link-grammar/blob/master/README.md Shows the Link Parser's output for the 'ady' language, demonstrating random morphological splittings and tagging. ```text linkparser> asdf qwerty fghjbbb Found 1512 linkages (1512 had no P.P. violations) +------------------ANY-----------------+ +-----ANY----+-------ANY------+ +---------LL--------+ | | | | | LEFT-WALL asdf[!ANY-WORD] qwerty[!ANY-WORD] fgh[!SIMPLE-STEM].= =jbbb[!SIMPLE-SUFF] ``` -------------------------------- ### CogServer Dockerfile Configuration (Dockerfile) Source: https://github.com/opencog/link-grammar/blob/master/link-grammar/dict-atomese/README.md The Dockerfile used to build the OpenCog CogServer environment. It specifies the base image, dependencies, and setup for running the CogServer. ```dockerfile # Example Dockerfile content for OpenCog CogServer # This is a simplified representation. FROM ubuntu:latest RUN apt-get update && apt-get install -y \ build-essential \ cmake \ git \ # Add other necessary dependencies here && rm -rf /var/lib/apt/lists/* # Clone and build OpenCog components (simplified) RUN git clone https://github.com/opencog/opencog /opt/opencog WORKDIR /opt/opencog RUN mkdir build && cd build && cmake .. && make -j && make install # Copy CogServer specific configurations or scripts # COPY ./cogserver-config /etc/opencog/ # Expose ports if necessary # EXPOSE 5701 # Command to run CogServer # CMD ["/usr/local/bin/cogserver", "--config", "/etc/opencog/cogserver.conf"] # The actual Dockerfile would be more detailed, including specific OpenCog versions and configurations. ``` -------------------------------- ### Vala Example: Parsing Sentences with Link Grammar Source: https://github.com/opencog/link-grammar/blob/master/bindings/vala/README.md Demonstrates how to use the Link Grammar Vala bindings to parse English sentences, generate linkages, and print diagrams. Requires the Link Grammar dictionary. ```vala public static int main (string[] args) { print ("# Link Grammar Sample\n"); string[] input_strings = { "He eats cake.", "He eat cake.", "The side affects were devastating.", "The side effects were devastating." }; var opts = new ParseOptions (); var dict = new Dictionary ("en"); // Allow for null links. opts.set_max_null_count (10); if (dict == null) { warning ("Could not load dictionary"); return 1; } for (int i = 0; i < input_strings.length; i++) { var sentence = new Sentence (input_strings[i], dict); sentence.split (opts); var num_linkages = sentence.parse (opts); if (num_linkages > 0) { var linkage = new Linkage (0, sentence, opts); var diagram = linkage.print_diagram (true, 800); print ("%s\n", diagram); } } return 0; } ``` -------------------------------- ### IJ Link: Connects Interjection to Left Wall (Thai) Source: https://github.com/opencog/link-grammar/blob/master/data/th/LINKDOC.md The 'IJ' link is an undirected link connecting an interjection word to the left wall. This example shows an interjection at the start of a sentence. ```Thai เฮ้ย _ มัน จะ เป็นไป ได้ หรือ hə́ɪ man tɕà pen.paɪ dâːɪ rɯ̌ː whoa it will happen ABLE QUES 'Whoa, how could it happen?' +--------------LWs--------------+ | +----------IJ----------+ | | +<----S<----+-----PT-----+ | +-PUs-+ | +AVw>+ | | | | | | | | LEFT-WALL เฮ้ย.ij _.pu มัน.pr จะ.x เป็นไป.v ได้.r หรือ.pt ``` -------------------------------- ### Link Grammar Python Setup Source: https://github.com/opencog/link-grammar/blob/master/msvc/README.md Provides instructions for setting up the environment when running Python programs that use the Link Grammar library bindings. This involves configuring PYTHONPATH and PATH, potentially using the provided `make-check.py` script. ```text Since the Link Grammar library has no installation script yet, running Python programs that use the bindings needs a careful setup of PYTHONPATH and PATH. A program named `make-check.py` (named after "make check" that runs `tests.py` in POSIX systems) is provided to set them automatically. Also see "Permanent installation". ``` -------------------------------- ### Override Install Prefix Configuration Source: https://github.com/opencog/link-grammar/blob/master/README.md Standard GNU configure option to override the default installation directory, allowing Link Grammar to be installed in a custom location. ```shell ./configure --prefix=/opt/link-grammar ``` -------------------------------- ### Build Environment Setup Macros Source: https://github.com/opencog/link-grammar/blob/master/msvc/README.md Defines essential user macros for the build process, including paths for Java SDK, Win flex-bison, and optional regex libraries. These are configured in project property sheets. ```APIDOC User Macro JAVA_HOME: Must point to a locally installed SDK/JDK with 'include' and 'include/win32' subdirectories. Alternatively, the JAVA_HOME environment variable can be used. User Macro WINFLEXBISON: Directory of the 'Win flex-bison' project (tested with version 2.5.9). Default is C:\win_flex_bison. Leave blank to use a ready pp_lexer.c file. User Macros GNUREGEX_DIR and LG_DLLPATH: Related to the optional external regex library. Can be safely ignored if not used. ``` -------------------------------- ### Link Crossing Examples in English Source: https://github.com/opencog/link-grammar/blob/master/README.md Provides example sentences in English that illustrate potential link crossing issues, particularly concerning temporal ordering and ambiguity in parsing. ```text Examples where the no-links-cross constraint seems to be violated, in English: "He is either in the 105th or the 106th battalion." "He is in either the 105th or the 106th battalion." Both seem to be acceptable in English, but the ambiguity of the "in-either" temporal ordering requires two different parse trees, ``` -------------------------------- ### Link Grammar Compilation Configuration Source: https://github.com/opencog/link-grammar/blob/master/msvc/README.md Instructions for configuring the build environment for Link Grammar. This includes selecting the solution platform (e.g., x64) and choosing between Debug and Release configurations for the build. ```text To compile LinkGrammar, open the solution file LinkGrammar.sln, change the solution platform to x64 if desired, and build. The solution configuration is configured to create a debug version by default. It's probably a good idea to switch a "Release" configuration. You can do this at **Build Menu->Configuration Manager**. ``` -------------------------------- ### Garden-Path Sentences Example Source: https://github.com/opencog/link-grammar/blob/master/README.md Illustrates garden-path sentences, which are syntactically ambiguous and can mislead parsers. These examples are crucial for testing parser robustness and identifying potential issues with Viterbi-style parsing approaches. ```text The horse raced past the barn fell. The old man the boat. The cotton clothing is made of grows in Mississippi. ``` -------------------------------- ### Display Configure Help Options Source: https://github.com/opencog/link-grammar/blob/master/README.md Command to display all available configuration options for the Link Grammar build system, useful for custom builds. ```shell ./configure --help ``` -------------------------------- ### Run Link Grammar Python Bindings Tests with Make Source: https://github.com/opencog/link-grammar/blob/master/bindings/python-examples/README.md Provides instructions on how to run the unit tests for the Link Grammar Python bindings using the `make` utility. It covers both running tests from the build directory and after installation. ```shell $ cd $BUILD_DIR/bindings/python-examples $ make [-s] check ``` ```shell $ cd $BUILD_DIR/bindings/python-examples $ make [-s] installcheck ``` -------------------------------- ### Link Grammar Parse: Verb Interpretation Source: https://github.com/opencog/link-grammar/blob/master/bindings/python-examples/parses-en.txt This example demonstrates how Link Grammar interprets a sentence where the verb is enclosed in brackets, suggesting a specific parsing behavior or annotation. ```Link Grammar IThieves rob bank O O +---------->WV---------->+ O +--->Wd---+------Sp------+ O | | | OLEFT-WALL thieves.n [rob] bank.v O ``` -------------------------------- ### Link Grammar: Collocations with Holes Examples Source: https://github.com/opencog/link-grammar/blob/master/README.md Illustrative examples of English collocations and phrasemes that contain 'holes' or missing elements, requiring special handling in syntactic parsing. These demonstrate patterns like 'from [xxx] on' and conditional structures. ```text "from [xxx] on." "He never said another word from then on." "I promise to be quiet from now on." "Keep going straight from that point on." "We went straight from here on." ... from there on. "We went straight, from the house on to the woods." "We drove straight, from the hill onwards." ``` ```text "First.. next..." "If ... then ..." "If it is raining, stay inside!" "If it is raining, [then] stay inside!" ``` ```text "if ... only ..." "If there were only more like you!" "... not only, ... but also ..." ``` ```text "As ..., so ..." "As it was commanded, so it shall be done" ``` ```text "Either ... or ..." "Both ... and ..." "Both June and Tom are coming" "ought ... if ..." "That ought to be the case, if John is not lying" ``` ```text "Someone ... who ..." "Someone is outside who wants to see you" ``` ```text "... for ... to ..." "I need for you to come to my party" ``` ```text "It ... that ..." "It seemed likely that John would go" ``` ```text "...from X and from Y" "By X, and by Y, ..." ``` ```text "the chip on X's shoulder" "to do X a favour" "to give X a look" ``` -------------------------------- ### Build Link Grammar on Windows (MinGW/MSYS2) Source: https://github.com/opencog/link-grammar/blob/master/mingw/README-MinGW64.md Steps to configure, build, and install the Link Grammar library on Windows using the MinGW/MSYS2 environment. This process involves setting up the build environment and executing standard build commands. ```Shell mkdir build cd build sh ../configure make make install ``` -------------------------------- ### Interjection and Particle Modifiers Example Source: https://github.com/opencog/link-grammar/blob/master/data/th/LINKDOC.md Illustrates how interjections (IJ) and particles (PT) can modify accepted constituents. This example shows a Thai phrase with an interjection and particle, along with its parse tree. ```Thai เฮ้ย _ ใน เรือน ปั้นหยา ไง hə́ɪ naɪ rɯaːn pânjǎː ŋaɪ hey in house hip-roofed EMPH 'Hey, in the hip-roofed house!' ``` ```Link Grammar Parse +---------LWp--------+ | +-----IJ----+---------PT---------+ | +-PUs-+ +->PO->+--NZ--+ | | | | | | | | LEFT-WALL เฮ้ย.ij _.pu ใน.pan เรือน.n ปั้นหยา.n ไง.pt ``` -------------------------------- ### Start Link Grammar JSON Network Server Source: https://github.com/opencog/link-grammar/blob/master/README.md Command to launch the Link Grammar parser as a TCP/IP network server. It listens on a specified port (defaulting to 9000 if omitted) and serves parse results as JSON messages. Requires Java and the linkgrammar.jar file. ```shell java -classpath linkgrammar.jar org.linkgrammar.LGService 9000 ``` -------------------------------- ### S Link Example: Subject-Verb Connection Source: https://github.com/opencog/link-grammar/blob/master/data/th/LINKDOC.md Explains the 'S' link, which connects a grammatical subject to its main verb. This example uses a Thai sentence and its parse tree to show the S link's function. ```Thai คณะ นักเรียน เดินทาง มา เชียงใหม่ kʰáná nák.rian dəːn.tʰaːŋ maː tɕʰiaŋ.màɪ group student travel come Chiang Mai 'A group of students are traveling to Chiang Mai.' ``` ```Link Grammar Parse +-----------LWs----------+ | +<-------S<------+ | +---NZ--+ +--VZ--+-->O->+ | | | | | | LEFT-WALL คณะ.n นักเรียน.n เดินทาง.v มา.v เชียงใหม่.n ``` -------------------------------- ### Meson Build Configuration for Link Grammar Vala Bindings Source: https://github.com/opencog/link-grammar/blob/master/bindings/vala/README.md Configures a Meson build system to find and link against the Link Grammar library and include its Vala API definitions for a project. ```meson # Find link-grammar dependency cc = meson.get_compiler('c') linkgrammar = cc.find_library('link-grammar', required: true) # Other build steps... executable( meson.project_name(), '...source_files...', c_args: c_args, dependencies: [ ...other dependencies..., linkgrammar ], vala_args: [ ...other Vala args..., meson.source_root() + '/vapi/link-grammar.vapi' ], install : true/false ) ``` -------------------------------- ### Link Grammar Parse: Complex Sentence Source: https://github.com/opencog/link-grammar/blob/master/bindings/python-examples/parses-en.txt Illustrates the Link Grammar parsing of a more complex sentence 'the quick brown fox jumped over the lazy dog'. This example shows detailed word connections and the hierarchical syntactic structure. ```Link Grammar Ithe quick brown fox jumped over the lazy dog O O +---------------->WV---------------->+ O +------------>Wd------------+ | O | +--------Ds**x-------+ | O | | +-------A------+ | O | | | +---A--+--Ss*s--+--MVp--+ O | | | | | | | OLEFT-WALL the quick.a brown.a fox.n jumped.v-d over the lazy.a dog.n O C(S (NP the quick.a brown.a fox.n) C (VP jumped.v-d C (PP over C (NP the lazy.a dog.n)))) C ``` -------------------------------- ### Configure Build on FreeBSD Source: https://github.com/opencog/link-grammar/blob/master/README.md Configures the build process on FreeBSD, specifying library paths, C compiler, and C++ compiler. This is necessary due to potential C++ library mixing issues with GCC and the common practice of using Clang on FreeBSD. ```bash env LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include \ CC=clang CXX=clang++ configure ``` -------------------------------- ### RW Link Example: Sentence with Right Wall Source: https://github.com/opencog/link-grammar/blob/master/data/th/LINKDOC.md Demonstrates the 'RW' link, connecting the last element of an utterance to the right wall. This example shows a sentence parse including the RW link, typically visible with the '!walls' flag. ```Thai ฉัน ไป โรงเรียน tɕʰǎn paɪ roːŋ.rian I go school 'I go to school.' ``` ```Link Grammar Parse +-----LWs-----+--------RW-------+ | +<-S<-+-->O->+ | | | | | | LEFT-WALL ฉัน.pr ไป.v โรงเรียน.n RIGHT-WALL ``` -------------------------------- ### Python Bindings Dependencies Source: https://github.com/opencog/link-grammar/blob/master/msvc/README.md Lists the required software and tools for building Python bindings for Link Grammar. This includes Python distributions and the SWIG interface generator. ```APIDOC Python Bindings Requirements: - Python3 distributions (from Python Releases for Windows). - SWIG (tested with swigwin-4.0.2). - Tested with Python 3.4.4. ``` -------------------------------- ### Generate Configure Script Source: https://github.com/opencog/link-grammar/blob/master/README.md Generates the 'configure' script from source files when building from the GitHub repository. This is a prerequisite step before running the 'configure' command itself. ```bash autogen.sh ``` -------------------------------- ### Thai Language Example Source: https://github.com/opencog/link-grammar/blob/master/README.md Demonstrates the Link Parser's output for a Thai sentence, showing POS tags and named entities. The Thai dictionary accepts LST20 tagsets. ```text | +<---S<---+-->O-->+ +<--AXw<-+--->O--->+ | | | | | | | | | LEFT-WALL เมื่อวานนี้.n[!] มี.ve[!] คน.n[!] มา.x[!] ติดต่อ.v[!] คุณ.pr[!] ครับ.pt[!] ``` ```text linkparser> linkparser> วันที่_25_ธันวาคม@DTM ของ@PS ทุก@AJ ปี@NN เป็น@VV วัน@NN คริสต์มาส@NN Found 348 linkages (348 had no P.P. violations) Linkage 1, cost vector = (UNUSED=0 DIS= 1.00 LEN=10) +--------------------------------LWs--------------------------------+ | +<------------------------S<------------------------+ | | +---------->PO--------->+ | | +----->AJpr----->+ +<---AJj<--+ +---->O---->+------NZ-----+ | | | | | | | | LEFT-WALL วันที่_25_ธันวาคม@DTM[!] ของ@PS[!].pnn ทุก@AJ[!].jl ปี@NN[!].n เป็น@VV[!].v วัน@NN[!].na คริสต์มาส@NN[!].n ``` -------------------------------- ### CogServer Docker Build (Shell) Source: https://github.com/opencog/link-grammar/blob/master/link-grammar/dict-atomese/README.md Shell script to build the OpenCog Docker image, which includes setting up a CogServer environment. This is used for the CogServer demo. ```shell git clone https://github.com/opencog/docker cd docker/opencog ./docker-build.sh -s -u ``` -------------------------------- ### Link Grammar Parse Diagram Example Source: https://github.com/opencog/link-grammar/blob/master/README.md Illustrates a complex parse tree structure in Link Grammar, highlighting the visual representation of links between words and the challenges posed by link crossing. ```text +---->WV---->+ | +--------IV---------->+ | | +<-VJlpi--+ | | | +---xxx------------Js------->+ +--Wd--+-Sp*i+--TO-+-I*t-+-MVp+ +--VJrpi>+--MVp-+---Js->+ | | | | | | | | | | LEFT-WALL I.p want.v to.r look.v at and.j-v listen.v to.r everything ``` -------------------------------- ### Create Link Grammar Demo Dictionary Source: https://github.com/opencog/link-grammar/blob/master/link-grammar/dict-sql/README.md Provides a sequence of shell commands to create a new demo dictionary using SQLite. This involves setting up a directory, copying files, importing SQL data, and then using the link-parser with the new dictionary. ```shell mkdir data/foo cp data/demo-sql/4.0.* data/foo cat dict.sql |sqlite3 data/foo/dict.db cat demo.sql |sqlite3 data/foo/dict.db link-parser foo ``` -------------------------------- ### Link Grammar Parser Output Example (Thai) Source: https://github.com/opencog/link-grammar/blob/master/README.md Presents the link-grammar parser's output for a Thai sentence, demonstrating the VS link for serial verb constructions and the general linkage structure. ```text linkparser> นายกรัฐมนตรี ขึ้น กล่าว สุนทรพจน์ Linkage 1, cost vector = (UNUSED=0 DIS= 2.00 LEN=2) +---------LWs--------+ | +<---S<--+--VS-+-->O-->+ | | | | | LEFT-WALL นายกรัฐมนตรี.n ขึ้น.v กล่าว.v สุนทรพจน์.n ``` -------------------------------- ### Guile Scheme: Link Grammar Parsing Example Source: https://github.com/opencog/link-grammar/blob/master/link-grammar/dict-atomese/README.md This snippet shows how to initialize the Link Grammar parser in Guile Scheme, parse a given phrase, and store the results in the AtomSpace. It requires specific OpenCog modules and a configured storage node for dictionary data. ```guile-scheme $ guile (use-modules (opencog) (opencog exec)) (use-modules (opencog nlp)) (use-modules (opencog nlp lg-parse)) (use-modules (opencog persist) (opencog persist-file)) (define fsn (FileStorage "/usr/local/share/link-grammar/demo-atomese/atomese-dict.scm")) (cog-open fsn) (define pda (LgParseDisjuncts (PhraseNode "Mary saw a bird") (LgDictNode "demo-atomese") (Number 4) (cog-atomspace) fsn)) (cog-execute! pda) (cog-prt-atomspace) (cog-incoming-set (Predicate "*-LG connector string-*")) (cog-incoming-set (Predicate "*-LG disjunct string-*")) ```