NLP++

From Natural Philosophy Wiki
(Redirected from NLP)
Jump to navigation Jump to search
NLP++
NLPppLogo-150x150.png
The NLP++ Logo
Paradigms Natural Language Processing
Designed by Amnon Meyers David de Hilster
Developer Text Analysis International
First appeared Template:Start date and age
Template:Infobox software/simple
Platform Cross Platform
OS Linux, Windows, Mac
Filename extensions .nlp, .pat, .seq, .txxt, .dict, .kbb .kb
Website www.visualtext.com

NLP++ is a computer programming language for natural language processing created by Amnon Meyers and David de Hilster in 1998 based on a cognitive model of how humans read and understand natural language. It operates on an input text via multiple passes that elaborate a best-first parse tree. It can access and update a hierarchical knowledge base management system (KBMS) called Conceptual Grammar (CG). NLP++ and CG deploy with an Integrated Development Environment (IDE) called VisualText, which supports rapid development of text analyzers. NLP++ is the only computer language exclusively dedicated to natural language processing.

Overview

NLP++ is a computer language dedicated to building natural language text analyzers. It allows programmers to capture and apply linguistic and world knowledge, emulating processes by which humans read and understand text. NLP++ combines bottom up, island-driven, recursive grammar, and other methods in a multi-pass architecture that operates on one parse tree. It works with a hierarchical knowledge base (KB), called Conceptual Grammar (CG), to dynamically build and use stored knowledge in analyzing text. Applications range from simple syntactic processing to full natural language understanding. VisualText is a developer's environment that exploits NLP++ and CG to rapidly elaborate text analyzers. Passes and KBs from one analyzer may be exploited to more rapidly construct and tailor new text analyzers.

NLP++

NLP++ is a computer language that takes text, breaks it down into tokens, builds up those tokens into syntactic trees, and builds and uses knowledge stored in Conceptual Grammar. The language includes functions, rules, operators, and variables specific to its internal representations of text and knowledge. NLP++ comprises general C or C++-lke programming language constructs, as well as integrally addressing rule matches and the associated knowledge base.

Variables

Variables are written with a single letter and a string name. Special variable types in NLP++ apply to specific contexts.

Variable Description Example Scope
N Specific node N("$text",2) Rules
S Suggested node S("count") Rules
X Context node and level X("concept",3) Rules
G Global variable G("People") Rules & Functions
L Local variable L("num") Rules & Functions

Regions

There are numerous regions in NLP++ files:

Region Description Position and Scope
@NODES Specifies the nodes to be matched in the @RULES region Comes before the @RULES region
@PATH Specifies a specific path in the syntax tree to match Comes before the @RULES region
@CODE Specifies a region where NLP++ code is executed outside of a @RULES region Region ends with @@CODE
@DECL Declarative area for functions Region ends with @@DECL
@POST Specifies a region of post processing for a rule or rules Comes right before the @RULES region
@PRE Specifies a region of preprocessing for a rule or rules Comes right before the @RULES region
@CHECK Specifies certain conditions on rule nodes before trying to match the rule Comes right before the @POST or @RULES region
@RULES Specifies a region for rules Region ends with @@

Rules

NLP++ has rules for pattern matching. A rule is written in the form of "@RULES _node <- a b c @@" where "<-" where a, b, and c are match and put under the new node "_node". Here is an example of a rule.

@POST
S("count") = N("$text",2);
S("concept") = makeconcept(G("Counts"),N("$text",1));
single();

@RULES
_count <-
    _xALPHA [s]  ### (1)
    _xNUM [s]    ### (2)
    @@

Built In Functions

NLP++ has built in functions for the following areas:

  • Knowledge Base Functions
  • Parse Tree Functions
  • String Functions
  • Special Functions
  • Math Functions
  • Spelling Functions
  • Formatting and I/O Functions
  • Web Functions
  • Database Functions

Analyzer Sequence

Analyzer sequence display of the full English parser written by Amnon Meyers

The analyzer sequence in NLP++ is a linear pipeline of executed NLP++ code. This code can contain rules, function declarations, or pure NLP++ code.

This facilitates bottom-up, island-driven parsing which is much more efficient that the combinatoric traversing of full grammars.

The analyzer sequence is contained in the file "analyzer.seq". Here is the analyzer sequence for a date-time analyzer:

dicttokz nil
nlp	init	
nlp	KBFuncs	
nlp	funcs	
nlp	LinesDictTokZ	
nlp	numbers	
nlp	ordinals	
nlp	times	
nlp	zulu	
nlp	timePhrases	
nlp	dates	
nlp	datesDay	
nlp	dateTime	
nlp	datePhrases	
nlp	splice	
nlp	kb	
nlp	output	

User Functions

NLP++ allows the user to create their own functions in the @@DECL area. These functions can access the syntactic tree and any part of the knowledge base, as well as files on the system.

Conceptual Grammar

The conceptual grammar is a hierarchical knowledge base that can be imported and used by NLP++ and also created by NLP++ code and pattern matching. The hierarchy contains concepts and concepts can have attributes and phrases attached to them.

VisualText

VisualText version 2 for Windows

VisualText is an IDE that is specifically built to edit, run, and debug NLP++ text analyzers. It includes a text director of texts to process, a special editor for NLP++, text highlighting of matching rules for each sequential pass of rule patterns, and tree visualizations for the syntactic tree as well as the hierarchical knowledge base. It also has the ability to quickly generate rules directly from text.

History

The roots of NLP++ come from its two creators, Amnon Meyers and David de Hilster who are computer programmers working in the area of natural language processing since the early 1980s.

Amnon Meyers

Amnon Meyers got his MS in Computer Science UC Berkeley, MS in Organic Chemistry UC Berkeley, and a BS in biology MIT. Amnon spent over a decade in aerospace NLP R&D (McDonnell Douglas & TRW) in the artificial intelligence groups developing VOX and the conceptual grammar which was developed in LISP. Amnon worked for 5 years at UC Irvine AI Lab on DARPA/Navy projects. In 1997, Amnon secured funding from friends and family to state Text Analysis International in order to create a computer programming language and IDE for creating natural language processing systems.

David de Hilster

David de Hilster got his BS in mathematics and MA in linguistics from the Ohio Statue University. De Hilster first developed island-driven pattern matching rules first in LISP on Xerox 1108 machines at Battelle Memorial Institute in their artificial intelligence group. He then worked in C for the commercial product called NLQuery from Battelle Memorial Institute. In the late 1980s, de Hilster developed Verbo, a natural language query system for databases in Portuguese while living in working in Rio de Janeiro Brazil.

Collaboration

In 1990, David de Hilster was hired into the Artificial Intelligence group at McDonnell Douglas in Huntington Beach California where he met Amnon and was tasked to move Amnon's Vox program to C++. The two collaborated, combining the island-driven parsing with the conceptual grammar and coming up with TexUS. Their system was used in the Message Understanding Conferences sponsored by Darp in the early 1990s and they placed third among the participants which included MIT, SRI, Carnegie Mellon among others.

In the mid 1990s, the two moved to the Artificial Intelligence Group at Space Park at TRW where the two continued their collaboration, with de Hilster's work inspiring the creation of a new company ISearch which electronically processed resumes. In 1997, de Hilster was hired by ISearch to move their text processing system to the C language.

In 1998, Meyers secured funding from friends and family to start Text Analysis International which eventually lured de Hilster to join where the two created and formalized NLP++ and VisualText. The idea was to formalize a computer language that incorporated the pattern matching of de Hilster's, with the Conceptual Grammar knowledge base from Meyers, along with an integrated development environment specifically tailored to NLP++, its tree structures, and its knowledge base.

For the two decades, the technology was privately owned and was licensed by private companies to process medial, social media, historical documents, and real estate text.

Open Source

VSCode NLP++ Language Extension

In December of 2018, NLP++ and VisualText went open source. The company Text Analysis International was dissolved by and it was moved to an open-source MIT licensed repository by creators Amnon Meyers and David de Hilster.

NLP Engine

The NLP engine is a C++ class and executable that can called by other languages that can call c++ libraries or call the nlp.exe executable. It currently compiles on Linux and will be available on windows and Mac Os in the near future. The nlp.exe executable is called by the NLP++ Language Extension for VSCode.

Command Line Executable

The NLP Engine in the form of a command line executable called "nlp.exe" is available for all three platforms in GitHub including Linux, Windows, and MacOS. The nlp.exe file is accompanied by two ICU (International Components for Unicode) allowing the engine to deal with Unicode languages including emojis.

Python Package and Class

A python package and class are available for the NLP Engine.

The NLPPlus Python Package integrates the NLP Engine's C++ code directly into a an Python Package and is the most efficient use of the NLP Engine when using Python. The NLPPlus Python Package is a package file that can be downloaded from the VisualText github library py-package-nlpengine and installed using pip. It is not yet available as an official python package on pypip.org due to the backlog of approving new organizations for python packages.

There is also a simple NLP Engine Python Class that is available that calls the NLP Engine as an command line executable that is less efficient than the NLPPlus Python Package. This is found in the python repository under the VisualText github main repository.

VisualText

All versions of VisualText are now also open source. Version 2 and 3 are no longer supported but heavily used (almost exclusively Version 2). The new VSCode Extension version will be the supported version of the IDE and runs on windows, macs, and Linux.

Windows Version

The C++ code for Version 2 and 3 of VisualText are now open source but they are currently unsupported. They both use commercial C++ libraries from CodeJock making future support in the open source world impossible. The downloads are still available from the VisualText website. Version 3 is also available but was never completed and is not 100 percent functional.

VSCode Language Extension

VisualText IDE is now ported to VSCode as a language extension which runs cross platform. This is now considered to be the current version of the IDE and will continue to be developed and enhanced. It was officially released as a Microsoft VSCode Language Extension on December 22, 2020 whose source code can be found in the VSCode-NLP repository on GitHub.

The NLP++ Language uses human readable files for dictionaries, knowledge bases, the syntactic tree, and for the NLP++ computer language:

File Extension Description
.nlp (.pat legacy) Files containing NLP++ code. The legacy files use the .pat (pattern) extension and are the only files understood by the windows versions of the VisualText IDE.
.seq The analyzer sequence file that store the calling order of the sequence of nlp++ files
.tree Tree files that display the current syntactic tree for a give pass
.txxt Rules matching highlight files containing double square or curly brackets around matched words and phrases (new to the VSCode NLP++ Language Extension)
.kbb Human readable Conceptual Grammar files (kbb = knowledge base beautiful files)
.dict Human readable dictionary files that are looked up during the initial tokenization pass
.kb (legacy) Legacy files dumped by the built-in function kbdumptree which is used to save and read in knowledge bases by NLP++. Except for some bootstrapping language files, these have been replaced by the more human-readable kbb files.

The long-term plan is to take ownership of the .nlp extension for NLP++ given it is the only computer language exclusively dedicated to natural languaage.

External links

References