use length control for summary
This commit is contained in:
@@ -35,6 +35,19 @@ getDataFromWPJSON = function (sourceUrl, page = 1, maxPosts = 10) {
|
||||
});
|
||||
};
|
||||
|
||||
summarizeText = function (text, length, clearText=true){
|
||||
|
||||
if (clearText){
|
||||
text = htmlToText.fromString(post.content.rendered,{
|
||||
wordwrap:false,
|
||||
ignoreHref:true,
|
||||
ignoreImage:true
|
||||
});
|
||||
}
|
||||
|
||||
return summarizer(text,{n:length});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAnswerFromWP: function (sourceUrl) {
|
||||
//This function will extract needed data from JSON, which we got from getDataFromWPJSON
|
||||
@@ -73,12 +86,11 @@ module.exports = {
|
||||
|
||||
try {
|
||||
rawData.forEach (post => {
|
||||
let textData = htmlToText.fromString(post.content.rendered,htmlToTextOptions);
|
||||
result += includeTitle ? post.title.rendered : '';
|
||||
result += includeTitle
|
||||
? `<break time="${constants.voiceResponseTimings.PAUSE_BETWEEN_TITLE_AND_CONTENT}ms"/>`
|
||||
: '';
|
||||
result += summarizer (textData);
|
||||
result += summarizeText(post.content.rendered,3);
|
||||
result += `<break time="${constants.voiceResponseTimings.PAUSE_BETWEEN_NEWS}ms"/>`;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user