Skip to content

Commit

Permalink
Implement "getrefs SBLGNT LXX Psalms N", version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Feb 5, 2022
1 parent 11480f6 commit 1200f25
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ The available commands are:
* `minunique1` *Bible*: Search for minimal unique passages in clipboard 1 in the given *Bible*.
* `extend` *Bible1* *Bible2* *book2* *passage2*: Extend the given passage in *Bible2* according to the longest possible citation from *Bible1*, based on the text of *book2* in *passage2*. In most cases `LXX` is used for *Bible1* and `SBLGNT` for *Bible2*.
* `psalminfo` *Bible* *number*: Show the number of verses in Psalm *number* in the given *Bible*.
* `getrefs` *Bible2* *Bible1* *book1* *passage1*: Search for references in *Bible2* on the passage in *Bible1* in book *book1* in *passage1*. Usually `SBLGNT` stands for *Bible2* and `LXX` for *Bible1*.
* `getrefs` *Bible2* *Bible1* *book1* *passage1*: Search for references in *Bible2* on the passage in *Bible1* in book *book1* in *passage1*. Usually `SBLGNT` stands for *Bible2* and `LXX` for *Bible1*. If *book1* is `Psalms`, the passage can also be its number only.
* `maxresults` *number*: Set the maximal amount of results to be shown to *number*.
* `compare12`: Compare the two clipboards with a 2-long substring-fingerprint (2-shingles) check, best match is reached at 1/(length1+length2).
* `jaccard12`: Compare the two clipboards the same way how `compare12` does but use the "Jaccard similarity for bags" algorithm, best match is reached at 0.
Expand Down
24 changes: 20 additions & 4 deletions cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ vector<string> vocabulary {addbooksCmd, compareCmd + "12", jaccardCmd + "12",
textCmd + "1", textCmd + "2", lookupCmd + "1", lookupCmd + "2", "quit",
"help", findCmd + "1", findCmd + "2", lengthCmd + "1", lengthCmd + "2",
minuniqueCmd + "1", latintextCmd + "1", latintextCmd + "2",
extendCmd, getrefsCmd, lookupCmd, maxresultsCmd, sqlCmd
extendCmd, getrefsCmd, lookupCmd, maxresultsCmd, sqlCmd, psalminfoCmd
};

void add_vocabulary_item(string item) {
Expand Down Expand Up @@ -532,8 +532,24 @@ string cli_process(char *buf) {
goto end;
}
if (restSize == 4) {
verse1S = tokens[3] + "+0";
verse1E = tokens[3] + "-0";
if (book1 == "Psalms") {
vector<string> r;
boost::split(r, tokens[3], boost::is_any_of(":"));
if (r.size() == 1) { // only the psalm number is given
verse1S = r[0] + ":1+0";
try {
verse1E = r[0] + ":" + to_string(getPsalmLastVerse(moduleName1, stoi(r[0]))) + "-0";
} catch (exception &e) {
error(e.what());
}
} else { // one verse is given in the psalm
verse1S = tokens[3] + "+0";
verse1E = tokens[3] + "-0";
}
} else { // this is not a psalm and one verse is given
verse1S = tokens[3] + "+0";
verse1E = tokens[3] + "-0";
}
} else if (restSize == 5) {
verse1S = tokens[3];
verse1E = tokens[4];
Expand Down Expand Up @@ -575,7 +591,7 @@ void cli(const char *input_prepend, const char *output_prepend, bool addbooks, b
#ifndef __EMSCRIPTEN__
rl_attempted_completion_function = completer;
#endif
info("This is bibref-cli 2022Jan12, nice to meet you.");
info("This is bibref-cli 2022Feb05, nice to meet you.");
showAvailableBibles();
if (addbooks) {
if (addBooks() == 0) {
Expand Down

0 comments on commit 1200f25

Please sign in to comment.