@@ -77,6 +77,7 @@ string quitCmd = "quit";
77
77
string helpCmd = " help" ;
78
78
string statementCmd = " statement" ;
79
79
string statementCmd2 = " Statement" ;
80
+ string nearestCmd = " nearest" ;
80
81
81
82
string errorNotRecognized
82
83
= " Sorry, the command you entered was not recognized or its syntax is invalid." ;
@@ -108,6 +109,7 @@ string errorMisc = "Sorry, there were some problems with the command you entered
108
109
vector<string> commands{addbooksCmd,
109
110
compareCmd + " 12" ,
110
111
jaccardCmd + " 12" ,
112
+ nearestCmd + " 12" ,
111
113
textCmd + " 1" ,
112
114
textCmd + " 2" ,
113
115
lookupCmd + " 1" ,
@@ -288,6 +290,9 @@ string getHelp(const string &key)
288
290
" check, best match is reached at 1/(length1+length2)." ,
289
291
" * `jaccard12`: Compare the two clipboards the same way how `compare12` does but use the "
290
292
" \" Jaccard similarity for bags\" algorithm, best match is reached at 0." ,
293
+ " * `nearest12`: Find a substring of clipboard1 such that its Jaccard similarity for bags "
294
+ " to clipboard2 is minimal." ,
295
+ " \" Jaccard similarity for bags\" algorithm, best match is reached at 0." ,
291
296
" * `sql` *switch*: Set some outputs to be shown also as an SQL query if *switch* is `on`." ,
292
297
" * `colors` *switch*: Show some outputs colored if *switch* is `on`." ,
293
298
" * `tokens` *Bible* *book* *verse*: Search for the given *verse* in the given *book* in "
@@ -678,6 +683,18 @@ void processJaccardCmd()
678
683
}
679
684
}
680
685
686
+ void processNearestCmd ()
687
+ {
688
+ if (textset.at (0 ) && textset.at (1 )) {
689
+ string best_c_d = best_jaccard_substr (text[1 ], text[0 ]);
690
+ vector<string> tokens;
691
+ boost::split (tokens, best_c_d, boost::is_any_of (" " ));
692
+ info (" Nearest Jaccard distance is " + tokens[1 ] + " with substring " + tokens[0 ] + " ." );
693
+ } else {
694
+ error (" Text 1 or 2 is not set." );
695
+ }
696
+ }
697
+
681
698
void processPsalminfoCmd (string input)
682
699
{
683
700
vector<string> tokens;
@@ -960,6 +977,8 @@ string cli_process(char *buf)
960
977
processCompareCmd ();
961
978
else if (boost::starts_with (input, jaccardCmd + " 12" ))
962
979
processJaccardCmd ();
980
+ else if (boost::starts_with (input, nearestCmd + " 12" ))
981
+ processNearestCmd ();
963
982
else if (boost::starts_with (input, minuniqueCmd + " 1" ))
964
983
processMinuniqueCmd (input);
965
984
// TODO: Consider using this trick for the other commands:
0 commit comments