GithubHelp home page GithubHelp logo

samestrin / sentiment-summary Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 315 KB

The sentiment-summary module generates summaries from larger bodies of text considering sentence-level sentiment. Multiple summarization algorithms and sentiment analysis engines are supported.

Home Page: https://sentiment-summary-documentation.netlify.app/

License: MIT License

JavaScript 100.00%
nlp rank sentiment summarization summarizer text textrank javascript node nodejs

sentiment-summary's Introduction

Sentiment Summary

Star on GitHub Fork on GitHub Watch on GitHub

Version 0.0.1 License: MIT Built with Node.js

The sentiment-summary npm module generates text summaries weighted by the sentiment expressed in individual sentences. It analyzes the sentiment of each sentence within a larger body of text and emphasizes or deemphasizes sentences based on their sentiment scores during the summarization process. This is an active project.

This module supports:

  • Seven different summarization algorithms: Extractive Text, Extractive Text Title Weighted, Latent Semantic Analysis (LSA), Maximum Marginal Relevance (MMR), TextRank, and TextRank with Word Embeddings.
  • Six different sentiment analysis engines: Hugging-Face, Natural, Sentiment (AFINN-165 based), sentiment-analysis (AFINN-111 based), VADER, and wink-sentiment.

Summarization Algorithms Supported:

Extractive Text:

The Extractive Text method ranks sentences based on the frequency of keywords or phrases they contain. Sentences with more frequent words or phrases are considered more important and included in the summary. It is a simple and efficient approach but may not capture semantic relationships or context, as well as other techniques.

Extractive Text Summarization Title Weighted:

This method ranks sentences based on the frequency of keywords or phrases they contain and the presence of words from the document's "title" section. The "title" is the first few sentences (1% of the total, up to a maximum of 3 sentences) in the input text. Words from these title sentences are considered more important and given additional weight when scoring each sentence. Sentences containing more frequent keywords or phrases and words from the title section are considered more important and included in the summary. While efficient, this approach may not fully capture semantic relationships or context as effectively as more advanced techniques.

Latent Semantic Analysis (LSA):

LSA is a technique that analyzes the relationships between a set of documents and the terms they contain. It constructs a semantic space where documents and terms are represented as vectors. In the context of text summarization, LSA can identify the most important sentences or passages that capture the core meaning and topics of the original text. It achieves this by finding the sentences with the highest semantic similarity to the overall document vector.

LexRank:

LexRank is a graph-based summarization method inspired by the PageRank algorithm used in web search engines. It constructs a graph representation of the text, where vertices represent sentences, and edges represent semantic similarity between sentences. The algorithm then computes a centrality score for each sentence, indicating its importance within the text. Highly scored sentences are selected to form the summary, capturing the most salient information.

Maximum Marginal Relevance (MMR):

MMR is a technique that aims to produce summaries that are relevant to the original text and diverse in content. It iteratively selects sentences that are highly relevant to the document but minimally redundant with sentences already included in the summary. MMR balances relevance and diversity, resulting in summaries covering the main topics while minimizing repetition.

TextRank:

TextRank is another graph-based summarization method similar to LexRank. However, instead of using semantic similarity between sentences, TextRank constructs the graph using co-occurrence relationships between words or phrases. Vertices represent words or phrases, and edges represent co-occurrence links between them. The algorithm computes a centrality score for each word or phrase, and sentences containing the highest-ranked words or phrases are selected for the summary.

TextRank with Word Embeddings:

This approach combines the TextRank algorithm with word embeddings, dense vector representations of words that capture semantic and syntactic information. Instead of using co-occurrence relationships between words, this method computes sentence similarity using word embeddings. Sentences are represented as vectors by averaging or combining the word embeddings of their constituent words. The TextRank algorithm then operates on these sentence vectors to identify the most important sentences for the summary.

Installation

npm install sentiment-summary

Usage

@todo pending intial release update

Hugging Face Support

This module comes pre-configured with 24 Hugging Face models that can be used with the Hugging Face sentiment analysis engine. They are grouped into 6 categories:

  • Finance (8 models)
  • General (7 models)
  • Movies (1 Model)
  • News (3 Models)
  • Product Reviews (4 Models)
  • Restaurant Reviews (1 Models)

You can easily load any of these modules using their alias name value. To access a list of models:

const { getModels } = require("sentiment-summary");

models = getModels();
console.log(models);

If you'd prefer to use a custom model, you can use the global configuration object or the options object argument and set:

const { setup } = require("sentiment-summary");

setup({
  sentimentEngine: "hugging-face",
  sentimentEngineModel: yourDesiredModel,
});

async function main() {
  let summary = async sentimentSummary(text)
}

main();

or

const { sentimentSummary } = require("sentiment-summary");

async function main() {
  let summary = async sentimentSummary(text,
  {
    sentimentEngine: "hugging-face",
    sentimentEngineModel: yourDesiredModel,
  });
}

main();

Documentation

https://sentiment-summary-documentation.netlify.app/

Contribute

Contributions to this project are welcome. Please fork the repository and submit a pull request with your changes or improvements.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Share

Twitter Facebook LinkedIn

sentiment-summary's People

Contributors

samestrin avatar actions-user avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.