about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--swipeGuess.1.scd8
-rw-r--r--swipeGuess.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/swipeGuess.1.scd b/swipeGuess.1.scd
index 01d02c7..25c58bb 100644
--- a/swipeGuess.1.scd
+++ b/swipeGuess.1.scd
@@ -5,19 +5,25 @@ swipeGuess - infer the word you meant from a swipe
 
 # SYNOPSIS
 
-*swipeGuess* _words.txt_ [_n_] < _input_swipes.txt_ > _output_guesses.tsv_
+*swipeGuess* _words.txt_ [_n_] [_ignorechars_] < _input_swipes.txt_ > _output_guesses.tsv_
 
 wvkbd -O | *swipeGuess* _words.txt_ | completelyTypeWord.sh
 
 wvkbd -O | *swipeGuess* _words.txt_ 5 | suggpicker | completelyTypeWord.sh
 
+wvkbd -O | *swipeGuess* _words.txt_ 1 "'" | completelyTypeWord.sh
+
 # OPTIONS
 _n_
 	Number of results that should be returned (default 1).
 
+_ignorechars_
+	Characters that exist in _words.txt_, but won't exist in your swipes, that you still want to type.
+
 # DESCRIPTION
 
 For each line of stdin, outputs the first _n_ results from _words.txt_ which could be an ordered subset of that line, separated by tabs.
+If _ignorechars_ is given, the results may have these characters inside them even when not present in the input.
 
 # SEE ALSO
 *suggpicker*(1) *wvkbd*(1) *SwipeBehavior*(7)
diff --git a/swipeGuess.c b/swipeGuess.c
index 41fb29c..44881a7 100644
--- a/swipeGuess.c
+++ b/swipeGuess.c
@@ -6,6 +6,7 @@
 #define BUFSIZE 1024
 char wordBuff[BUFSIZE];
 char swipeBuff[BUFSIZE];
+bool ignorechars[256] = {false};
 
 // fgets, but without the newline.
 char *fgetst(char *restrict s, int size, FILE *restrict stream) {
@@ -35,7 +36,7 @@ bool swipeCompare(char *swipe, char *word) {
 	bool lastMatch = false;
 	for(swipeP++; swipeP[0]; swipeP++) {
 		lastMatch = false;
-		while (charcmp(swipeP[0], wordP[0])) {
+		while (charcmp(swipeP[0], wordP[0]) || ignorechars[wordP[0]]) {
 			wordP++;
 			lastMatch = true;
 		}
@@ -70,6 +71,11 @@ int main(int argc, char **argv) {
 	if (argc >= 3) {
 		n = atoi(argv[2]);
 	}
+	if (argc >= 4) {
+		for(int i=0; argv[3][i];i++){
+			ignorechars[(int)argv[3][0]] = true;
+		}
+	}
 	FILE *wordFile = fopen(argv[1], "r");
 	while (fgetst(swipeBuff, BUFSIZE, stdin)) {
 		query(wordFile, swipeBuff, n);