Better API
jbrooksuk opened this issue · comments
Currently the module is almost a direct port of the original Python code, which is fine and dandy, however it doesn't really stay true to the Node.js way.
Since parsing the summary can take a couple of seconds - dependant on the content size - the EventEmitter
should be implemented so that the developer can bind to the events when the content has been summarized. Or we use a callback system.
At the same time, the getSentenceRanks
and getSummary
methods should be merged, with the result from getSentenceRanks
being parsed through as a return value to the new function, so statistics can be provided etc.
6fca5a3 introduced a new asynchronous API. I decided against EventEmitter as it seems to have sped up. Further testing will reveal whether it'll be worth doing it anyway.
The API is now also compressed into one function, summarize
. It takes a title, the content and a callback function.
SummaryTool.summarize(title, content, function(err, summary) {
if(err) console.log("Something went wrong.");
console.log(summary);
});
Hopefully that'll work a lot better.