JSPM

locale-string-summarizer

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q35161F
  • License MIT

Intelligent text summarizer with automatic language detection. Supports English, Spanish, and Russian. Extract keywords or get concise summaries with TypeScript support.

Package Exports

  • locale-string-summarizer
  • locale-string-summarizer/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (locale-string-summarizer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Locale String Summarizer

npm version MIT License

A lightweight TypeScript utility that intelligently summarizes text based on detected language/locale. Automatically detects the language and provides concise summaries or keyword extraction tailored to the specific locale.

Features

  • Automatic Locale Detection: Detects Spanish, Russian, and English text automatically
  • Smart Summarization: Extracts key sentences while preserving meaning
  • Keyword Extraction: Get the most important keywords from your text
  • Configurable Options: Customize sentence count and output format
  • Zero Dependencies: Lightweight with no external dependencies
  • TypeScript Support: Full type definitions included

Installation

npm install locale-string-summarizer

Usage

Basic Usage

import { summarizeText } from "locale-string-summarizer";

const text =
  "This is a very long sentence that contains multiple ideas and concepts. It should be summarized into a shorter version that captures the main points.";

// Basic summarization
const summary = summarizeText(text);
console.log(summary);
// Output: "This is a very long sentence that contains multiple ideas and concepts. It should be summarized into a shorter version that captures the main points."

Advanced Options

// Extract only keywords
const keywords = summarizeText(text, { keywordsOnly: true });
console.log(keywords);
// Output: "sentence, contains, multiple, ideas, concepts"

// Custom sentence count
const customSummary = summarizeText(text, { maxSentences: 1 });
console.log(customSummary);
// Output: "This is a very long sentence that contains multiple ideas and concepts."

Multi-language Support

// Spanish text
const spanishText =
  "Este es un texto muy largo en español que contiene múltiples ideas y conceptos.";
const spanishSummary = summarizeText(spanishText);
console.log(spanishSummary);

// Russian text
const russianText =
  "Это очень длинный текст на русском языке который должен быть сокращен.";
const russianSummary = summarizeText(russianText);
console.log(russianSummary);

API Reference

summarizeText(text: string, options?: SummarizerOptions): string

Summarizes the input text based on detected locale.

Parameters:

  • text (string): The input text to summarize
  • options (SummarizerOptions, optional): Configuration options

SummarizerOptions:

  • maxSentences?: number - Maximum number of sentences to return (default: 2)
  • keywordsOnly?: boolean - If true, returns only keywords instead of sentences (default: false)

Returns: string - The summarized text or keywords

Supported Languages

  • English (en) - Default fallback
  • Spanish (es) - Detected by accented characters (á, é, í, ó, ú, ñ, ü)
  • Russian (ru) - Detected by Cyrillic characters

License

MIT © Harsh Srivastava

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.