Implements rule connection algorithm#155
Conversation
|
I'm happy to continue working on this to optimise performance. This is just a first implementation. Would be good to hear your thoughts @sverhoeven |
|
Actually I was wrong it seems, Wordnet is much smaller: https://wordnet.princeton.edu/download/current-version thats good news! Just tens of MBs. But also I am doing calls to the Wordnet API for every pair of token comparisons using the natural.js library. So perhaps one call upfront to download the entire db into localStorage could make it much faster too. Then we just do calls to the local db. |
Turns out that natural.js downloads wordnet (it does not do remote API calls) so that was not the reason for the very slow computation. See here. So I just implemented basic caching of word lookups and filtering only relevant parts of wordnet based on the tokens in the Statement array inputs. It's much faster. 5 seconds for 20 statements. Yay! But I think we should consider using an alternative to natural.js because it says on the natural.js documentation page: "Keep in mind that the WordNet integration is to be considered experimental at this point, and not production-ready. The API is also subject to change. For an implementation with vastly increased performance, as well as a command-line interface, see wordpos." |
|
In nlp-route branch I tested if I could run the code in browser sadly it Can you replace natural with https://github.com/moos/wordpos-web , which is made to run in browser, while natural performs NodeJS calls which can never run in browser. |
Okay, I will look in to this @sverhoeven |
Preview deployments for INA-tool ⚡️
Commit: Deployment ID: Static site name: |
…ionary subsets - no raw wordnet files are used to reduce load time
|
@sverhoeven I tried to take a different approach by taking the subsets of wordnet I require at this stage and storing them as JS objects here and here and I use compromise.js for the rest. The code passes my current test suite, but I imagine I will have to extend these dictionaries and the test suite to make it more robust. Let me know if you can at least build and test it for the browser though :) |
|
Yep it works in #161, which is now also prettier and moved compute from main ui thread to web worker. |
Thanks @sverhoeven! Do you intend to add a button to the component and statement level network panels for this functionality? So that when the user clicks on it, the edges are automatically drawn after computation? Or do you foresee that the user would prefer to use the separate "NLP analysis" section in the menu? |
Dunno yet. Users might want to approve/dismiss found connections then a separate page is easier. Also a separate page was easier to implement for debugging. |
|
I combined your work with my UI in #161 . |


A combination of wordnet and compromise.js are used