Advertisement
Guest User

Untitled

a guest
May 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. function getPercentages(text) {
  2. var myJSONObject = {
  3. "documents": [{
  4. "language": "en",
  5. "id": "1",
  6. "text": text
  7. }]
  8. };
  9. fetch('https://francecentral.api.cognitive.microsoft.com/text/analytics/v2.1/sentiment', {
  10. method: 'POST',
  11. headers: { "Ocp-Apim-Subscription-Key": "718a10e484374595a185d7b640303912" ,
  12. "Content-Type" : "application/json" ,
  13. "Accept": "application/json" },
  14. body: JSON.stringify(myJSONObject)
  15. }).then(function (response) {
  16. return response.json();
  17. }).then(function (data) {
  18. console.log(data.documents[0].score);
  19. });
  20. }
  21. getPercentages("Hello Fuck you idiot!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement