Skip to content

DataTemple Command Line Tool

jrising edited this page Apr 11, 2013 · 16 revisions

DataTemple: Natural Language Templates

The template engine identifies phrases the match flexible English language structures.

You can download the tool from http://existencia.org/datatemple/DataTemple-Basic.zip

Command line arguments:

  • -h or --help: Direction to this page
  • -c or --conf [directory]: Path to the Virsona Plugin Data directory
  • -v or --verbose: Increase the level of verbosity
  • -s: Serial mode, see below
  • -z: Spell-checking mode, see below
  • -I [input text]: Match against the provided input string
  • -i [input file]: Read the input from a file
  • --tag: Return a part-of-speech tagged representation of the input
  • --parse: Return a parse tree representation of the input
  • -P [preprocessor commands]: Any definitions to run before the template
  • -T [template text]: Try to match the given template
  • -O [command text]: If the -T template is matched, execute the following command
  • -p [preprocessor file]: Read each line in the file as a preprocessor command
  • -t [templates file]: Read pairs of lines as template-command combinations (like -T and -O)

Templates and Commands

Please see Template Syntax for Extraction.

Pre-processor Definitions

You can make definitions before running your template with the -p argument. The syntax is,

-P "@defwc %name word word word ..."

Here's an example:

mono DataTemple.exe -c ../config.xml -P "@defwc %defeats defeats beats conquers" -T "%sentence %noun %defeats *" -O "@print %noun - %defeats - *" -I "Might beats right."

Serial Mode

When DataTemple is in serial mode (adding -s to the command line), the whole system inches through the sentences one at a time, and for each sentence, tries each template in order and stop after the first match. This guarantees that each sentence is only matched once.

Templates need to be defined in the order they are to be matched, and all need to start with either %sentence or %sentences.

Spell-checking Mode

When in spell-checking mode (with the -z flag), possible spelling corrections are considered for all word matches, and if the sentence fails because of parsing matches, the entire sentence is modified to use correctly spelled words and the match is attempted again.

The spell-checking relies on Hunspell, a powerful, open-source spell-checker based on MySpell. You can install it at http://hunspell.sourceforge.net/

An Overview

Here's a conceptual model of what the tools does. I'll write up what it means eventually.

Basic Structure

The Backend

Here's an example of the tool in action. I'll write up a corresponding description eventually.

DataTemple Process