Giter VIP home page Giter VIP logo

anagrammar's Introduction

anagrammar

generate anagrams that obey a grammar

Anagrammar provides libraries, and a command line utility, that let you compile grammars like this:

female_name        -> female_first_part last_part?
female_name        -> last_part
female_first_part  -> <female_title> female_post_title?
female_first_part  -> female_post_title
female_post_title  -> <female> female_middle_part?
female_post_title  -> female_middle_part
female_middle_part -> <initial>{1,3}
female_middle_part -> <female>{1,2} <surname>{1,2}
female_middle_part -> <female>{1,2}
female_middle_part -> <surname>{1,2}

last_part -> <epithet>? <surname> <suffix>?

into a finite state automaton like this:

female_names

compile the necessary wordlists into tries, and then generate from a particular phrase all the anagrams of that phrase that fit within the wordlists and grammar.

Usage

If you compile the command line utility, it will give you usage information in the usual way. Note that you need my CLI library to compile the code.

~ $ java -jar anagrammar.jar --help
USAGE: anagrammar [options] <word>*

  compute the anagrams of a phrase that obey a specified grammar

    --grammar -g   <str>   specify a grammar to use rather than the default
                           listed in /Users/houghton/.anagrammar/config
    --out -o       <file>  dump output -- anagrams, grammar, or Graphviz spec
                           -- into this file
    --sample -s    <int>   produce only a sample of anagrams; value must be > 0
    --random -r            generate anagrams in random order
    --unique -u            in case the grammar can produce the same phrase in
                           more than one way, this ensures that each name is only
                           listed once; NOTE: for the sake of memory efficiency 
                           and speed, hashcodes are used to determine uniqueness,
                           so some anagrams may be dropped altogether
    --count -c             print out the number of anagrams found

    --default      <str>   set the default grammar
    --list -l              list available grammars
    --word-lists           show the list of word lists used by the grammars
    --dot                  print out a Graphviz graph specification for the
                           finite state automaton representation of a grammar
    --show-grammar         dump out the selected grammar

    --threads      <int>   maximum number of threads; value must be > 0;
                           default: 8

    --initialize           generate a skeleton configuration file in
                           /Users/houghton/.anagrammar; you must then modify this
                           configuration file to specify grammars and word lists
    --force                in conjunction with --initialize, this overwrites an
                           existing configuration file

    --version -v           print anagrammar version
    --help -? -h           print usage information

This utility allows you to generate all the anagrams of a phrase that obey a 
particular grammar. In order to do this it needs a grammar and word lists that 
define the acceptable values of terminal nodes in the grammar. For instance, you
might have the grammar

  name -> <first>
  name -> <last>
  name -> <first> <last>

This grammar says a name can be a "first" by itself, a "last" by itself, or a 
"first" followed by a "last". Just what these things are must be specified by two
word lists: first and last. To use this grammar, you must configure this 
application to find the grammar and the word lists. Run the --initialize command
if you have not already and then edit the configuration file it generates to tell
anagrammar where to find the grammar file and the word lists it requires. A 
specification of the grammar formalism can be found in the README file in the 
same directory as the configuration file.

The aforementioned README is here.

anagrammar's People

Contributors

dfhoughton avatar

Watchers

 avatar James Cloos avatar  avatar

anagrammar's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.