Closed shev72 closed 1 year ago
Mmmm... AbbottSmithStrongs is returned (example based on Ezra Bible App).
However, there is a filter in place for dictionary modules - based on the requirements from Ezra Bible App. By default, only dictionary modules that come with Strongs keys are returned, see this section of the code.
If needed, we could change this default behavior by at least making it configurable via the API.
As I looked at your script I saw that you use the default behavior of getAllRepoModules
which is to only return BIBLE modules. Based on that you do not see any dictionary modules in your output - AbbottSmithStrongs is just one of them. If you want to get Dictionary modules, you need to set the parameter moduleType
to 'DICT', like this:
var modules = interface.getAllRepoModules(repo, 'DICT');
That should also give you AbbottSmithStrongs in return ... but not the dictionary modules that do not have Strongs keys.
This page may answer your question about manually installing modules you downloaded. https://crosswire.org/sword/modules/moduleinstall.jsp
On Windows, the location of the SWORD directory should be:
C:\Users\<user-name>\AppData\Roaming\sword
many thanks for your detailed comments!
I have a follow-up question, I am able to download and install the module following your comments, however I don't see any functions for retrieving the text, or some strong code => definition mapping or word to translation mapping in the api.
I have tried in the code snipped below, to get a bookCode and use the getText methods, but I think there are no codes defined.
I see also there are some functions for getting translations, but how can I retrieve the list of available words with Strong Keys? It seems those methods are somehow tied to a bookCode.
////////////// // CODE SNIPPET ///////////
var mod = interface.getLocalModule(moduleName);
console.log(mod.description+mod.about); //this works //OUTPUT=> //G. Abbott-Smith's A Manual Greek Lexicon (with Strongs) of the New TestamentAbbott-Smith is a project // to mark up the G. Abbott-Smith's A Manual Greek Lexicon of the New Testament (New York: Scribner's, 1922) using TEI.
//THIS fails var books= interface.getBookList(moduleName);
// I was hoping to get a code and start examining the text of Abbot Smith s= interface.getBookText(moduleName,books[0]);
Ok, I can see how this is not a straightforward use case when working with node-sword-interface. So you are trying to look up entries specifically in dictionary modules? Note that the text-related functions (like getBookList
, getBookText
) in node-sword-interface are only working with Bible modules, not with Dictionary modules.
Looking up entries in dictionary modules is only designed for looking up Strongs based entries. This means you would have to first determine the Strongs key and then based on that you could get the respective Dictionary entry like this:
let strongsKey = 'G1680';
let entry = interface.getRawModuleEntry(moduleName, strongsKey);
If you give me some additional information about your complete use case, it may be easier for me to support further.
Hello, thanks for your example, I tested , but unfortunately the code fails. I stepped through with the debugger, and it seems to just crash without an exception.
looking at the API, I think there is no call such as GetAllAvailableKeys(module); This would help debugging as I can then be sure the key exists (but it should, that's a standard key).
I am able to get the keys from other module, just by parsing the KJV strong module for example.
My code is below (basically your method call), I tested with several Gxxx numbers.
Conecrning my use case, it is simple for the moment I just would like to link KJVStrong bible to strong number definitions for display on a webpage.
Also: I am happy to make a pull request(s) for code which may be useful to others ( I will clean up and document, it could be added to examples subdirectory) , as this is quite a useful wrapper, c++ is no longer as popular as before, and few people are able to to work with C++ apis today, so many thanks for the api!
function outputDictionaryData(moduleName){ var mod = interface.getLocalModule(moduleName); console.log(mod.description+mod.about); //this works let strongsKey = 'G803'; let entry = interface.getRawModuleEntry(moduleName,strongsKey); console.log(entry); } var mod="AbbottSmithStrongs"; outputDictionaryData(mod);
Just a quick follow-up point: there are probably other alternives (eg getting the xml for abbot LExicon in XML and parsing directly, I have seen an xml version online), but if there is an api for this already then it is much simpler.
There was an error in my example from earlier. The Strongs keys are without the initial letter.
So it should be like this instead (using the NASB Greek dictionary):
let moduleName = 'NASGreek';
let strongsKey = '1680';
let entry = interface.getRawModuleEntry(moduleName, strongsKey);
There is currently no function to list all keys from a Dictionary. In case of Ezra Bible App it does not make much sense in the UI to list keys like 0001, 0002, 0003, ... Rather I let the user work with the Bible text that already contains the keys.
Here is how I use this in Ezra Bible App:
1.) You open a Bible module that comes with Strongs numbers in the markup of each verse. 2.) The user can hover over the words in a verse and the respective Strongs Nr. is extracted from the verse markup. 3.) The Strongs entry in the dictionaries is looked up using the extracted Strongs Nr. from the selected verse/word.
I checked some entries of the AbbottSmithStrongs module, but it seams like it is not very useful when using the Strong's numbers as keys (screenshot from Ezra Bible App):
It just contains some kind of links to the respective Greek words. Maybe it would then show the full dictionary entry when using the Greek word as key. I have not tried that yet.
Yes, you could also work with XML files that you download somewhere. However, the nice thing with the SWORD library is that you get access to all sorts of modules - all with the same interface / handling.
It seems that some modules are available online , but don't appear in any repository.
Is there some way to manually download the module?
I have download AbbottSMithStrongs.zip, but I guess I now have to unzip and place the files somewhere to be able to use the node interface.
I wrote a small script below which outputs to a file all the modules available per repository, and in the result I don't find AbbottSMithStrongs so I was wondering if I could do it manually.
const NodeSwordInterface = require('C:/Users/shelb/node_modules/node-sword-interface'); const fs = require('fs/promises');
var interface = new NodeSwordInterface();
function getModulesInRepo(repo){ var modules=interface.getAllRepoModules(repo); var f=repo+".txt"; var s=""; for (var i = 0; i < modules.length; i++) { // console.log( 'moduleName : ' + JSON.stringify(modules[i]) + '\n'); s+=repo+' // moduleName : ' + modules[i].name + '; strong='+modules[i].hasStrongs+ '\n'; } return s; }
async function printRepoNames() { console.log("Updating repository configuration ..."); // await interface.updateRepositoryConfig();
fs.writeFile("repoContents.txt",s);
}
printRepoNames();