sdr 0.5

net.cscott.sdr.calls.grm
Class CompletionEngine

java.lang.Object
  extended by net.cscott.sdr.calls.grm.CompletionEngine

public class CompletionEngine
extends Object

Uses Grm.grammar(Program) to compute possible completions for a partially-input call.

We are careful about expanding "+" and "*" to avoid generating an infinite list of options. We only expand once past the end of the given input.

Tests:
Get completions for partial phrases, based on the grammar:
js> importPackage(net.cscott.sdr.calls);
js> function c(txt) {
  >   for (s in Iterator(CompletionEngine.complete(Program.PLUS, txt, 100))) {
  >     print(s);
  >   }
  > }
js> c("sq");
square thru
square thru <cardinal>
square thru and roll
square thru <number>
square thru <number> <cardinal>
square thru <number> and roll
square thru <number> hands
square thru <number> hands <cardinal>
square thru <number> hands and roll
square thru <number> hands around
square thru <number> hands around <cardinal>
square thru <number> hands around and roll
square thru <number> hands round
square thru <number> hands round <cardinal>
square thru <number> hands round and roll
js> c("square thru 1 1/2 h");
square thru 1 1/2 hands
square thru 1 1/2 hands <cardinal>
square thru 1 1/2 hands and roll
square thru 1 1/2 hands around
square thru 1 1/2 hands around <cardinal>
square thru 1 1/2 hands around and roll
square thru 1 1/2 hands round
square thru 1 1/2 hands round <cardinal>
square thru 1 1/2 hands round and roll
js> c("tr");
trade
trade <cardinal>
trade and roll
track <number>
track <number> <cardinal>
track <number> and roll
js> c("trade")
trade
trade <cardinal>
trade and roll
js> c("trade a");
trade and roll
trade and roll <cardinal>
trade and roll and roll
js> c("trade and roll");
trade and roll
trade and roll <cardinal>
trade and roll and roll
js> c("trade and roll a");
trade and roll and roll
trade and roll and roll <cardinal>
trade and roll and roll and roll
js> c("scoot back once a");
scoot back once and a half
scoot back once and a half <cardinal>
scoot back once and a half and roll
scoot back once and a third
scoot back once and a third <cardinal>
scoot back once and a third and roll
scoot back once and a quarter
scoot back once and a quarter <cardinal>
scoot back once and a quarter and roll
scoot back once and one half
scoot back once and one half <cardinal>
scoot back once and one half and roll
scoot back once and one third
scoot back once and one third <cardinal>
scoot back once and one third and roll
scoot back once and one quarter
scoot back once and one quarter <cardinal>
scoot back once and one quarter and roll
scoot back once and two thirds
scoot back once and two thirds <cardinal>
scoot back once and two thirds and roll
scoot back once and two quarters
scoot back once and two quarters <cardinal>
scoot back once and two quarters and roll
scoot back once and three quarters
scoot back once and three quarters <cardinal>
scoot back once and three quarters and roll

Constructor Summary
CompletionEngine()
           
 
Method Summary
static Iterator<String> complete(Program program, String input)
          Return an iterator over the possible completions for the input string at the given dance program.
static List<String> complete(Program program, String input, int limit)
          Return a size-limited list of possible completions for the input string at the given dance program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompletionEngine

public CompletionEngine()
Method Detail

complete

public static Iterator<String> complete(Program program,
                                        String input)
Return an iterator over the possible completions for the input string at the given dance program.


complete

public static List<String> complete(Program program,
                                    String input,
                                    int limit)
Return a size-limited list of possible completions for the input string at the given dance program.


sdr 0.5

Copyright © 2006-2009 C. Scott Ananian