The textery Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The textery Reference Manual

This is the textery Reference Manual, version 0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 05:58:34 2022 GMT+0.

Table of Contents


1 Introduction

textery

ava fox

implementation of tracery in lisp

Installation

$ git clone https://github.com/compufox/textery ~/common-lisp/textery
* (ql:quickload :textery)

Usage

Load a rule file (a normal tracery JSON file) using (load-grammar "rule.file")

If this is the first rule file loaded, it is set as the current grammar.

To expand text, use (expand "#expand# this!")

If you have multiple grammars loaded use the (with-grammar) macro to select which grammar to use:

(with-grammar "grammar2"
  (expand "#test#"))

You can pass arguments to the text to be expanded by using periods: (expand-text "#test.string-upcase#"), these can be chained together by doing (expand-text "#test.string-upcase.reverse#")

Arguments are any lisp function that can handle at least one string parameter. You can even provide your own!

If you want to use functions that require more than one parameter do as follows:

(defun example-argument (text param param2)
  (concatenate 'string
			   text
			   param
			   param2))

(expand "#test.example-argument(5,test)#")

API

(load-grammar file)

loads grammar from FILE

stores the contents internally under the FILE's name minus the extension

if this is the first grammar thats loaded, set our current grammar to it


(load-grammar-directory dir)

loads all grammars from directory DIR


(create-grammar name grammar)

manually creates a grammar using NAME and GRAMMAR

GRAMMAR is a tracery-formatted json string


(with-grammar grammar &body body)

executes BODY with GRAMMAR set to be the current grammar

GRAMMAR is the filename (minus extension) of the grammar file previous loaded


(list-grammars)

returns a list of all loaded grammars


(expand text)

expands TEXT using the current grammar


License

BSD 3-Clause


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 textery

tracery lisp implementation

Author

ava fox

License

BSD 3-Clause

Version

0.2

Dependencies
  • str (system).
  • cl-json (system).
  • uiop (system).
  • cl-ppcre (system).
Source

textery.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 textery/textery.asd

Source

textery.asd.

Parent Component

textery (system).

ASDF Systems

textery.


3.1.2 textery/package.lisp

Source

textery.asd.

Parent Component

textery (system).

Packages

textery.


3.1.3 textery/util.lisp

Dependency

package.lisp (file).

Source

textery.asd.

Parent Component

textery (system).

Internals

3.1.4 textery/eng-modifiers.lisp

Dependency

util.lisp (file).

Source

textery.asd.

Parent Component

textery (system).

Internals
  • a (function).
  • ed (function).
  • possesive (function).
  • s (function).

3.1.5 textery/textery.lisp

Dependency

eng-modifiers.lisp (file).

Source

textery.asd.

Parent Component

textery (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 textery

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: with-grammar (grammar &body body)

executes BODY with current-grammar set to GRAMMAR

Package

textery.

Source

textery.lisp.


Previous: , Up: Public Interface   [Contents][Index]

5.1.2 Ordinary functions

Function: create-grammar (name grammar)

creates a grammar from a string

NAME is a string that denotes what the grammar is to be called GRAMMAR is a string that contains tracery formatted json

Package

textery.

Source

textery.lisp.

Function: expand (text)

expands TEXT

Package

textery.

Source

textery.lisp.

Function: load-grammar (file)

loads the json grammar referred to by FILE

Package

textery.

Source

textery.lisp.

Function: load-grammar-directory (dir)

loads all grammars from directory DIR

Package

textery.

Source

textery.lisp.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Special variables

Special Variable: *action-rules*

rules added by actions
very volatile, only used during evaluations

Package

textery.

Source

textery.lisp.

Special Variable: *current-grammar*

current grammar being used

Package

textery.

Source

textery.lisp.

Special Variable: *grammars*

all currently loaded grammar files

Package

textery.

Source

textery.lisp.


Previous: , Up: Internals   [Contents][Index]

5.2.2 Ordinary functions

Function: a (word)

puts ’a’ or ’an’ in front of WORD

Package

textery.

Source

eng-modifiers.lisp.

Function: agetf (place indicator &optional default)

getf but for alists

Package

textery.

Source

util.lisp.

Function: apply-arguments (text arguments)

applies all ARGUMENTS to TEXT

ARGUMENTS is a list of strings that refer to lisp functions

Package

textery.

Source

util.lisp.

Function: c= (char &rest compare)

returns non-nil if CHAR is one of COMPARE characters

Package

textery.

Source

util.lisp.

Function: ed (word)

naively applies ’ed’ to the end of WORD

Package

textery.

Source

eng-modifiers.lisp.

Function: get-all-actions (text)

retrieves all actions from TEXT

Package

textery.

Source

util.lisp.

Function: get-all-symbols (text)

retrieves all symbols from TEXT

Package

textery.

Source

util.lisp.

Function: grammar-value (key)

returns a value from the current grammar using KEY

Package

textery.

Source

textery.lisp.

Function: json-string-to-symbol (json-string &key as-string as-keyword)

converts camelCase JSON-STRING to a symbol

if AS-STRING is non-nil, returns a string instead of a symbol if AS-KEYWORD is non-nil, returns a keyword

Package

textery.

Source

util.lisp.

Function: last-letter (word)

gets last letter of WORD

Package

textery.

Source

util.lisp.

Function: list-grammars ()

returns a list of loaded grammars

Package

textery.

Source

textery.lisp.

Function: parse-func-arguments (funcname funcall)

parses arguments passed into FUNCALL

returns a list of arguments, or nil

Package

textery.

Source

util.lisp.

Function: parse-function (name)

returns a function of name NAME

Package

textery.

Source

util.lisp.

Function: possesive (word)

naively converts WORD into its possesive form

Package

textery.

Source

eng-modifiers.lisp.

Function: process-actions (actions text)

processes all ACTIONS, removing them from TEXT

Package

textery.

Source

textery.lisp.

Function: process-symbols (symbols text)

processes all SYMBOLS, evaluating and replacing them in TEXT

Package

textery.

Source

textery.lisp.

Function: random-from-list (lst)

returns a random element from LST

Package

textery.

Source

util.lisp.

Function: replace-first (old new s)

replaces the first occurance of OLD with NEW in S

if OLD isn’t found in S, returns S as-is

Package

textery.

Source

util.lisp.

Function: s (word)

naively pluralizes WORD

Package

textery.

Source

eng-modifiers.lisp.

Function: vowel-p (char)

returns non-nil is CHAR is a vowel

Package

textery.

Source

util.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   C   E   F   G   J   L   M   P   R   S   V   W  
Index Entry  Section

A
a: Private ordinary functions
agetf: Private ordinary functions
apply-arguments: Private ordinary functions

C
c=: Private ordinary functions
create-grammar: Public ordinary functions

E
ed: Private ordinary functions
expand: Public ordinary functions

F
Function, a: Private ordinary functions
Function, agetf: Private ordinary functions
Function, apply-arguments: Private ordinary functions
Function, c=: Private ordinary functions
Function, create-grammar: Public ordinary functions
Function, ed: Private ordinary functions
Function, expand: Public ordinary functions
Function, get-all-actions: Private ordinary functions
Function, get-all-symbols: Private ordinary functions
Function, grammar-value: Private ordinary functions
Function, json-string-to-symbol: Private ordinary functions
Function, last-letter: Private ordinary functions
Function, list-grammars: Private ordinary functions
Function, load-grammar: Public ordinary functions
Function, load-grammar-directory: Public ordinary functions
Function, parse-func-arguments: Private ordinary functions
Function, parse-function: Private ordinary functions
Function, possesive: Private ordinary functions
Function, process-actions: Private ordinary functions
Function, process-symbols: Private ordinary functions
Function, random-from-list: Private ordinary functions
Function, replace-first: Private ordinary functions
Function, s: Private ordinary functions
Function, vowel-p: Private ordinary functions

G
get-all-actions: Private ordinary functions
get-all-symbols: Private ordinary functions
grammar-value: Private ordinary functions

J
json-string-to-symbol: Private ordinary functions

L
last-letter: Private ordinary functions
list-grammars: Private ordinary functions
load-grammar: Public ordinary functions
load-grammar-directory: Public ordinary functions

M
Macro, with-grammar: Public macros

P
parse-func-arguments: Private ordinary functions
parse-function: Private ordinary functions
possesive: Private ordinary functions
process-actions: Private ordinary functions
process-symbols: Private ordinary functions

R
random-from-list: Private ordinary functions
replace-first: Private ordinary functions

S
s: Private ordinary functions

V
vowel-p: Private ordinary functions

W
with-grammar: Public macros

Jump to:   A   C   E   F   G   J   L   M   P   R   S   V   W