Get started with nlp_compromise CDN

MIT licensed

Lightweight NLP toolkit: tokenization, POS tagging, named entity recognition .

Tags:
  • natural
  • language
  • nlp
  • compromise

Stable version

Copied!

How to start using nlp_compromise CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with nlp_compromise CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  <script src="https://cdn.cdnhub.io/nlp_compromise/7.0.0/nlp_compromise.min.js"></script>
  <script>
    async function processText() {
      const text = "I love playing soccer and eating pizza.";
      const apiKey = "YOUR_API_KEY"; // Replace with your API key

      const pipeline = new Compromise();

      // Perform NLP tasks
      const doc = pipeline.process(text);

      // Extract named entities
      const entities = doc.entities;

      // Extract sentiment analysis
      const sentiment = doc.sentiment.score;

      // Log the results
      console.log("Entities:", entities);
      console.log("Sentiment:", sentiment);

      // Make an API call to save the results
      const response = await axios.post('https://your-api.com/process', { text, entities, sentiment }, {
        headers: {
          'Content-Type': 'application/json',
          'Authorization': `Bearer ${apiKey}`
        }
      });

      console.log("API Response:", response.data);
    }

    processText();
  </script>
</head>
<body></body>
</html>

All versions