diff --git a/index.js b/index.js index bc89e67..abc2f60 100644 --- a/index.js +++ b/index.js @@ -5,11 +5,13 @@ const robots = { async function start() { const content = { + useFecthContentFromWikipediaAlgorithmia: false, maximumSentences: 7 } content.searchTerm = askAndReturnSearchTerm() content.prefix = askAndReturnPrefix() + content.lang = askAndReturnLanguage() await robots.text(content) @@ -25,6 +27,13 @@ async function start() { return selectedPrefixText } + function askAndReturnLanguage(){ + const language = ['pt','en', 'es', 'fr'] + const selectedLangIndex = readline.keyInSelect(language,'Choice Language: ') + const selectedLangText = language[selectedLangIndex] + return selectedLangText + } + console.log(JSON.stringify(content, null, 4)) } diff --git a/package-lock.json b/package-lock.json index 78e7853..04f8ddd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "resolved": "https://registry.npmjs.org/@types/csv-stringify/-/csv-stringify-1.4.3.tgz", "integrity": "sha512-vfbvOBhuTjDYQjdG8dCxLjOsyQMjCE0oN0bIUkJtiolqkCe1WTCjh36w4hEhtkdLHUgsB4aN4r6SFD8iLJgiGQ==", "requires": { - "@types/node": "*" + "@types/node": "10.3.6" } }, "@types/extend": { @@ -27,7 +27,7 @@ "resolved": "https://registry.npmjs.org/@types/file-type/-/file-type-5.2.2.tgz", "integrity": "sha512-GWtM4fyqfb+bec4ocpo51/y4x0b83Je+iA6eV131LT9wL0//G+1UgwbkMg7w61ceOwR+KkZXK00z44jrrNljWg==", "requires": { - "@types/node": "*" + "@types/node": "10.3.6" } }, "@types/form-data": { @@ -35,7 +35,7 @@ "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", "requires": { - "@types/node": "*" + "@types/node": "10.3.6" } }, "@types/is-stream": { @@ -43,7 +43,7 @@ "resolved": "https://registry.npmjs.org/@types/is-stream/-/is-stream-1.1.0.tgz", "integrity": "sha512-jkZatu4QVbR60mpIzjINmtS1ZF4a/FqdTUTBeQDVOQ2PYyidtwFKr0B5G6ERukKwliq+7mIXvxyppwzG5EgRYg==", "requires": { - "@types/node": "*" + "@types/node": "10.3.6" } }, "@types/node": { @@ -56,10 +56,10 @@ "resolved": "https://registry.npmjs.org/@types/request/-/request-2.47.1.tgz", "integrity": "sha512-TV3XLvDjQbIeVxJ1Z3oCTDk/KuYwwcNKVwz2YaT0F5u86Prgc4syDAp6P96rkTQQ4bIdh+VswQIC9zS6NjY7/g==", "requires": { - "@types/caseless": "*", - "@types/form-data": "*", - "@types/node": "*", - "@types/tough-cookie": "*" + "@types/caseless": "0.12.2", + "@types/form-data": "2.2.1", + "@types/node": "10.3.6", + "@types/tough-cookie": "2.3.5" } }, "@types/tough-cookie": { @@ -72,10 +72,10 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "co": "4.6.0", + "fast-deep-equal": "1.1.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "algorithmia": { @@ -88,7 +88,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "requires": { - "color-convert": "^1.9.0" + "color-convert": "1.9.3" } }, "array-uniq": { @@ -101,7 +101,7 @@ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", "requires": { - "safer-buffer": "~2.1.0" + "safer-buffer": "2.1.2" } }, "assert-plus": { @@ -114,7 +114,7 @@ "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", "requires": { - "lodash": "^4.17.11" + "lodash": "4.17.11" } }, "asynckit": { @@ -137,7 +137,7 @@ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "requires": { - "tweetnacl": "^0.14.3" + "tweetnacl": "0.14.5" } }, "buffer-from": { @@ -155,9 +155,9 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.5.0" } }, "co": { @@ -183,7 +183,7 @@ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { - "delayed-stream": "~1.0.0" + "delayed-stream": "1.0.0" } }, "core-util-is": { @@ -196,7 +196,7 @@ "resolved": "https://registry.npmjs.org/csv-stringify/-/csv-stringify-1.0.4.tgz", "integrity": "sha1-vBi6ua1M7zGV/SV5gLWLR5xC0+U=", "requires": { - "lodash.get": "^4.0.0" + "lodash.get": "4.4.2" } }, "dashdash": { @@ -204,7 +204,7 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" } }, "debug": { @@ -225,8 +225,8 @@ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", "requires": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" + "domelementtype": "1.3.1", + "entities": "1.1.2" } }, "domelementtype": { @@ -239,7 +239,7 @@ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", "requires": { - "domelementtype": "1" + "domelementtype": "1.3.1" } }, "domutils": { @@ -247,8 +247,8 @@ "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", "requires": { - "dom-serializer": "0", - "domelementtype": "1" + "dom-serializer": "0.1.1", + "domelementtype": "1.3.1" } }, "dotenv": { @@ -261,8 +261,8 @@ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" + "jsbn": "0.1.1", + "safer-buffer": "2.1.2" } }, "entities": { @@ -310,9 +310,9 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" + "asynckit": "0.4.0", + "combined-stream": "1.0.7", + "mime-types": "2.1.22" } }, "getpass": { @@ -320,7 +320,7 @@ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" } }, "har-schema": { @@ -333,8 +333,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "ajv": "^5.1.0", - "har-schema": "^2.0.0" + "ajv": "5.5.2", + "har-schema": "2.0.0" } }, "has-flag": { @@ -347,12 +347,12 @@ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", "requires": { - "domelementtype": "^1.3.1", - "domhandler": "^2.3.0", - "domutils": "^1.5.1", - "entities": "^1.1.1", - "inherits": "^2.0.1", - "readable-stream": "^3.1.1" + "domelementtype": "1.3.1", + "domhandler": "2.4.2", + "domutils": "1.7.0", + "entities": "1.1.2", + "inherits": "2.0.3", + "readable-stream": "3.2.0" } }, "http-signature": { @@ -360,9 +360,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "assert-plus": "1.0.0", + "jsprim": "1.4.1", + "sshpk": "1.16.1" } }, "ibm-cloud-sdk-core": { @@ -370,20 +370,20 @@ "resolved": "https://registry.npmjs.org/ibm-cloud-sdk-core/-/ibm-cloud-sdk-core-0.0.1.tgz", "integrity": "sha512-C8NyKBIVh892VG+7WU/+hd/c9zvHBZ19ZgjlRcTUMLh/lRCIORqehg2k4qqADLxxZipAcnP+ofX6rUKdbTuP+Q==", "requires": { - "@types/extend": "~3.0.0", - "@types/file-type": "~5.2.1", - "@types/is-stream": "~1.1.0", - "@types/node": "~10.3.5", - "@types/request": "~2.47.1", - "buffer-from": "~1.1.0", - "dotenv": "^6.2.0", - "extend": "~3.0.2", - "file-type": "^7.7.1", - "isstream": "~0.1.2", - "mime-types": "~2.1.18", - "request": "~2.87.0", - "semver": "^5.6.0", - "vcap_services": "~0.3.4" + "@types/extend": "3.0.1", + "@types/file-type": "5.2.2", + "@types/is-stream": "1.1.0", + "@types/node": "10.3.6", + "@types/request": "2.47.1", + "buffer-from": "1.1.1", + "dotenv": "6.2.0", + "extend": "3.0.2", + "file-type": "7.7.1", + "isstream": "0.1.2", + "mime-types": "2.1.22", + "request": "2.87.0", + "semver": "5.6.0", + "vcap_services": "0.3.4" }, "dependencies": { "dotenv": { @@ -403,7 +403,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "requires": { - "is-plain-object": "^2.0.4" + "is-plain-object": "2.0.4" } }, "is-plain-object": { @@ -411,7 +411,7 @@ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "requires": { - "isobject": "^3.0.1" + "isobject": "3.0.1" } }, "is-typedarray": { @@ -505,7 +505,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", "requires": { - "mime-db": "~1.38.0" + "mime-db": "1.38.0" } }, "ms": { @@ -518,6 +518,11 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.1.tgz", "integrity": "sha512-I6YB/YEuDeUZMmhscXKxGgZlFnhsn5y0hgOZBadkzfTRrZBtJDZeg6eQf7PYMIEclwmorTKK8GztsyOUSVBREA==" }, + "node-fetch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz", + "integrity": "sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==" + }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", @@ -533,7 +538,7 @@ "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-3.0.0.tgz", "integrity": "sha512-EO+BCv6LJfu+gBIF3ggLicFebFLN5zqzz/WWJlMFfkMyGth+oBkhxzDl0wx2W4GkLzuQs/FsSkXZb2IMWQqmBQ==", "requires": { - "is-extendable": "^1.0.0" + "is-extendable": "1.0.1" } }, "object.pick": { @@ -541,7 +546,7 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "requires": { - "isobject": "^3.0.1" + "isobject": "3.0.1" } }, "performance-now": { @@ -554,9 +559,9 @@ "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.14.tgz", "integrity": "sha512-NsbD6XUUMZvBxtQAJuWDJeeC4QFsmWsfozWxCJPWf3M55K9iu2iMDaKqyoOdTJ1R4usBXuxlVFAIo8rZPQD4Bg==", "requires": { - "chalk": "^2.4.2", - "source-map": "^0.6.1", - "supports-color": "^6.1.0" + "chalk": "2.4.2", + "source-map": "0.6.1", + "supports-color": "6.1.0" }, "dependencies": { "supports-color": { @@ -564,7 +569,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } } } @@ -584,9 +589,9 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz", "integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==", "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "inherits": "2.0.3", + "string_decoder": "1.2.0", + "util-deprecate": "1.0.2" } }, "readline-sync": { @@ -599,26 +604,26 @@ "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", - "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", - "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "tough-cookie": "~2.3.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" + "aws-sign2": "0.7.0", + "aws4": "1.8.0", + "caseless": "0.12.0", + "combined-stream": "1.0.7", + "extend": "3.0.2", + "forever-agent": "0.6.1", + "form-data": "2.3.3", + "har-validator": "5.0.3", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.22", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.2", + "safe-buffer": "5.1.2", + "tough-cookie": "2.3.4", + "tunnel-agent": "0.6.0", + "uuid": "3.3.2" } }, "safe-buffer": { @@ -636,16 +641,16 @@ "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.20.0.tgz", "integrity": "sha512-BpxXkBoAG+uKCHjoXFmox6kCSYpnulABoGcZ/R3QyY9ndXbIM5S94eOr1IqnzTG8TnbmXaxWoDDzKC5eJv7fEQ==", "requires": { - "chalk": "^2.4.1", - "htmlparser2": "^3.10.0", - "lodash.clonedeep": "^4.5.0", - "lodash.escaperegexp": "^4.1.2", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.mergewith": "^4.6.1", - "postcss": "^7.0.5", - "srcset": "^1.0.0", - "xtend": "^4.0.1" + "chalk": "2.4.2", + "htmlparser2": "3.10.1", + "lodash.clonedeep": "4.5.0", + "lodash.escaperegexp": "4.1.2", + "lodash.isplainobject": "4.0.6", + "lodash.isstring": "4.0.1", + "lodash.mergewith": "4.6.1", + "postcss": "7.0.14", + "srcset": "1.0.0", + "xtend": "4.0.1" } }, "sbd": { @@ -653,7 +658,7 @@ "resolved": "https://registry.npmjs.org/sbd/-/sbd-1.0.14.tgz", "integrity": "sha512-jrpm6EnGL4IFjzmvlQAyjaec0fnmUd8TNBnCdoq8jw1IeJXDg8129C8I6U1rNBSU42hb523Euj6ik0DTBjx6pw==", "requires": { - "sanitize-html": "^1.18.4" + "sanitize-html": "1.20.0" } }, "semver": { @@ -671,8 +676,8 @@ "resolved": "https://registry.npmjs.org/srcset/-/srcset-1.0.0.tgz", "integrity": "sha1-pWad4StC87HV6D7QPHEEb8SPQe8=", "requires": { - "array-uniq": "^1.0.2", - "number-is-nan": "^1.0.0" + "array-uniq": "1.0.3", + "number-is-nan": "1.0.1" } }, "sshpk": { @@ -680,15 +685,15 @@ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" + "asn1": "0.2.4", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.2", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.2", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "safer-buffer": "2.1.2", + "tweetnacl": "0.14.5" } }, "string_decoder": { @@ -696,7 +701,7 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "5.1.2" } }, "supports-color": { @@ -704,7 +709,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } }, "tough-cookie": { @@ -712,7 +717,7 @@ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "requires": { - "punycode": "^1.4.1" + "punycode": "1.4.1" } }, "tunnel-agent": { @@ -720,7 +725,7 @@ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "5.1.2" } }, "tweetnacl": { @@ -733,7 +738,7 @@ "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", "requires": { - "is-typedarray": "^1.0.0" + "is-typedarray": "1.0.0" } }, "util-deprecate": { @@ -756,9 +761,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "^1.0.0", + "assert-plus": "1.0.0", "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" + "extsprintf": "1.3.0" } }, "watson-developer-cloud": { @@ -766,27 +771,27 @@ "resolved": "https://registry.npmjs.org/watson-developer-cloud/-/watson-developer-cloud-3.18.2.tgz", "integrity": "sha512-lUkCptpI0+F2x/C2r2PcodJfjbtvbIPcTYfnz+mAYwdY291AknKiSDPwz/5L2w46SG2yEpWbBaWUqWftr36Mqg==", "requires": { - "@types/csv-stringify": "~1.4.2", - "@types/extend": "~3.0.0", - "@types/file-type": "~5.2.1", - "@types/is-stream": "~1.1.0", - "@types/node": "~10.3.5", - "@types/request": "~2.47.1", - "async": "~2.6.1", - "buffer-from": "~1.1.0", - "csv-stringify": "~1.0.2", - "dotenv": "^2.0.0", - "extend": "~3.0.2", - "file-type": "^7.7.1", + "@types/csv-stringify": "1.4.3", + "@types/extend": "3.0.1", + "@types/file-type": "5.2.2", + "@types/is-stream": "1.1.0", + "@types/node": "10.3.6", + "@types/request": "2.47.1", + "async": "2.6.2", + "buffer-from": "1.1.1", + "csv-stringify": "1.0.4", + "dotenv": "2.0.0", + "extend": "3.0.2", + "file-type": "7.7.1", "ibm-cloud-sdk-core": "0.0.1", - "isstream": "~0.1.2", - "mime-types": "~2.1.18", - "object.omit": "~3.0.0", - "object.pick": "~1.3.0", - "request": "~2.87.0", - "semver": "^5.6.0", - "vcap_services": "~0.3.4", - "websocket": "~1.0.26" + "isstream": "0.1.2", + "mime-types": "2.1.22", + "object.omit": "3.0.0", + "object.pick": "1.3.0", + "request": "2.87.0", + "semver": "5.6.0", + "vcap_services": "0.3.4", + "websocket": "1.0.28" } }, "websocket": { @@ -794,10 +799,10 @@ "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.28.tgz", "integrity": "sha512-00y/20/80P7H4bCYkzuuvvfDvh+dgtXi5kzDf3UcZwN6boTYaKvsrtZ5lIYm1Gsg48siMErd9M4zjSYfYFHTrA==", "requires": { - "debug": "^2.2.0", - "nan": "^2.11.0", - "typedarray-to-buffer": "^3.1.5", - "yaeti": "^0.0.6" + "debug": "2.6.9", + "nan": "2.13.1", + "typedarray-to-buffer": "3.1.5", + "yaeti": "0.0.6" } }, "xtend": { diff --git a/package.json b/package.json index 66aa1dc..38035f3 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "homepage": "https://github.com/filipedeschamps/video-maker#readme", "dependencies": { "algorithmia": "^0.3.10", + "node-fetch": "^2.3.0", "readline-sync": "^1.4.9", "sbd": "^1.0.14", "watson-developer-cloud": "^3.18.2" diff --git a/robots/text.js b/robots/text.js index 4b15de0..5c8ffe9 100644 --- a/robots/text.js +++ b/robots/text.js @@ -1,6 +1,7 @@ const algorithmia = require('algorithmia') const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey const sentenceBoundaryDetection = require('sbd') +const fetch = require('node-fetch') const watsonApiKey = require('../credentials/watson-nlu.json').apikey const NaturalLanguageUnderstandingV1 = require('watson-developer-cloud/natural-language-understanding/v1.js') @@ -12,21 +13,47 @@ var nlu = new NaturalLanguageUnderstandingV1({ }) async function robot(content) { - await fetchContentFromWikipedia(content) + + if(content.useFecthContentFromWikipediaAlgorithmia){ + await fecthContentFromWikipediaAlgorithmia(content) + }else{ + await fetchContentFromWikipedia(content) + } + sanitizeContent(content) breakContentIntoSentences(content) limitMaximumSentences(content) await fetchKeywordsOfAllSentences(content) - async function fetchContentFromWikipedia(content) { + async function fecthContentFromWikipediaAlgorithmia(content) { const algorithmiaAuthenticated = algorithmia(algorithmiaApiKey) const wikipediaAlgorithm = algorithmiaAuthenticated.algo('web/WikipediaParser/0.1.2') - const wikipediaResponse = await wikipediaAlgorithm.pipe(content.searchTerm) + //const wikipediaResponse = await wikipediaAlgorithm.pipe(content.searchTerm) + const wikipediaResponse = await wikipediaAlgorithm.pipe({ + "articleName": content.searchTerm, + "lang": content.lang + }) const wikipediaContent = wikipediaResponse.get() content.sourceContentOriginal = wikipediaContent.content } + async function fetchContentFromWikipedia(content) { + try { + const response = await fetch(`https://${content.lang}.wikipedia.org/w/api.php?action=query&prop=extracts&exintro=true&explaintext&titles=${encodeURIComponent(content.searchTerm)}&format=json`) + const wikipediaRawResponse = await response.json() + + const wikipediaRawContent = wikipediaRawResponse.query.pages + + Object.keys(wikipediaRawContent).forEach((key) => { + content.sourceContentOriginal = wikipediaRawContent[key]['extract'] + }) + + } catch (error) { + console.log(error) + } + } + function sanitizeContent(content) { const withoutBlankLinesAndMarkdown = removeBlankLinesAndMarkdown(content.sourceContentOriginal) const withoutDatesInParentheses = removeDatesInParentheses(withoutBlankLinesAndMarkdown)