You can try Lexeduct live in your web browser here: Lexeduct Online
"this is not a wheel I've re-invented before"
It is currently a work in progress. The current released version is 0.1. The framework and usage and everything is subject to change without notice.
Being a framework, Lexeduct inevitably handles some use cases well, and other use cases poorly. See the "Limitations" section below for more details.
The name "Lexeduct" is in analogy with "aqueduct": conduits for words intead of water.
The main tool is
lexeduct.js. You can
cd into the
src directory and run
./lexeduct.js, or you can put the
src directory on your executable
search path, for example like
and run it as
lexeduct.js from anywhere on your system. (YMMV on Windows.)
The basic usage is
So, for example,
$ echo 'Hello!' | lexeduct.js upper HELLO
Parameters can be given with the syntax
name=value before the name of the
transformer they are to be applied to:
$ echo 'Hello' | lexeduct.js chars=e remove-chars Hllo
You can of course use shell pipelines to compose transformers:
$ echo 'Hello!' | lexeduct.js upper | lexeduct.js chars=' ' insert-chars H E L L O !
Or you can name multiple transformers on
lexeduct.js's command line to
$ echo 'Hello!' | lexeduct.js upper chars=' ' insert-chars H E L L O !
Multiple transformers are applied left-to-right.
$ echo 'Hello!' | lexeduct.js chars=a insert-chars upper HAEALALAOA!A $ echo 'Hello!' | lexeduct.js upper chars=a insert-chars HaEaLaLaOa!a
The idea is that this repository will eventually contain a giant catalogue of possible text transformers that can be composed. Or at least, more than are presently included.
directory which exports, node-style, a single function called
which takes a configuration object and returns a transformer function. The
transformer function takes two arguments: the current string to process, and
(optionally) an object which can be used to store ancillary state. Every
transformer function should return either a string, or null (not yet supported),
or an array of strings (not yet supported.)
The module may also export a couple of other things, like an English description
of the transformer, and the possible configuration options. For a reasonably
simple example, see the source of the
upper transformer, in upper.js.
State deposited into the state object is shared by all transformers, so it's a good idea to choose a key that you think will probably be unique.
./make.sh from this directory (or the commands it contains) to generate
suitable for loading in an HTML document.
demo/lexeduct.html in your browser. It provides a UI for composing
these transformers and applying them to text provided in a textarea.
The main limitation is that every filter is line-based. Even the filters that work on words take a line, split it into words, do whatever it is they do to the words, then stick the words back together to form a new line, destroying any irregular spacing in the original line.
Lexeduct was partly inspired by, and is partly a product of parallel evolution resembling, Michael Paulukonis's TextMunger. It is also indebted to various and sundry discussion with him, and others on the GenerativeText Forum, particularly John Ohno.
git clone https://git.catseye.tc/Lexeduct/
- The Python build script is written in Python 3. Chris Pressey 1 year, 12 days ago
- Using this repo with Mercurial is deprecated, remove such files. Chris Pressey 2 years ago
- Update link to online installation of Lexeduct. Chris Pressey (commit: GitHub) 2 years ago
- Change how the demo page is populated (use launcher script.) Chris Pressey 5 years ago
- Don't try to run tests if node.js is not on the search path. Chris Pressey 6 years ago
- Don't require node to build; fall back to python if node missing. Chris Pressey 7 years ago
- Added tag 0.1 for changeset c0757bc54d3e Chris Pressey 8 years ago
- Merge. Chris Pressey 8 years ago
- Added tag 0.1 for changeset 9e704c8393a6 Chris Pressey 8 years ago
- Prep for release of version 0.1. Chris Pressey 8 years ago