npm package: @sxyzdevv/txtscan
Description: module yang melakukan scanner kepada text yang anda berikan
Author: Sxyz
Latest version: 0.0.6-rc

# @sxyzdevv/txtscan

[![npm version](https://img.shields.io/npm/v/@sxyzdevv/txtscan.svg)](https://www.npmjs.com/package/@sxyzdevv/txtscan)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue)](https://www.typescriptlang.org/)

A lightweight, powerful text analysis library for JavaScript and TypeScript applications. Analyze text content for sentiment, readability, keywords, and more with minimal setup.

## Features

- **Comprehensive Analysis**: Get word count, sentence count, paragraph count in one call
- **Keyword Extraction**: Automatically identify the most important keywords in a text
- **Sentiment Analysis**: Determine if text has positive, negative, or neutral sentiment
- **Readability Scoring**: Calculate how easy or difficult a text is to read
- **Performance Optimized**: Designed for speed and minimal memory footprint
- **Zero Dependencies**: No external dependencies required
- **TypeScript Ready**: Full type definitions included

## Installation

```bash
# Using npm
npm install @sxyzdevv/txtscan

# Using yarn
yarn add @sxyzdevv/txtscan

# Using pnpm
pnpm add @sxyzdevv/txtscan
```

## Quick Start

```typescript
import { analyzeText } from '@sxyzdevv/txtscan';

const text = `
Hari ini adalah hari yang cerah. Matahari bersinar terang di langit biru.
Burung-burung berkicau dengan riang. Saya merasa sangat bahagia hari ini.
`;

const analysis = analyzeText(text);
console.log(analysis);
```

Output:

```javascript
{
  wordCount: 19,
  sentenceCount: 4,
  paragraphCount: 1,
  topKeywords: ['hari', 'cerah', 'matahari', 'bersinar', 'terang'],
  sentiment: 'positive',
  readability: {
    score: 83,
    level: 'Mudah dibaca'
  }
}
```

## API Reference

### `analyzeText(text: string)`

Performs a comprehensive analysis of the provided text.

**Parameters:**
- `text` (string): The text to analyze

**Returns:**
An object containing:
- `wordCount`: Total number of words
- `sentenceCount`: Total number of sentences
- `paragraphCount`: Total number of paragraphs
- `topKeywords`: Array of the 5 most frequently used meaningful words
- `sentiment`: Sentiment classification ('positive', 'negative', or 'neutral')
- `readability`: Object containing readability metrics
  - `score`: Readability score (0-100)
  - `level`: Readability level ('Mudah dibaca', 'Sedang', or 'Sulit dibaca')

## Extended Example

```typescript
import { analyzeText } from '@sxyzdevv/txtscan';

// Analyze an article
const article = `
# Pentingnya Menjaga Kesehatan Mental

Kesehatan mental sama pentingnya dengan kesehatan fisik. Banyak orang yang mengabaikan kondisi mental mereka. Padahal, kesehatan mental yang baik dapat meningkatkan produktivitas dan kualitas hidup.

Ada beberapa cara untuk menjaga kesehatan mental:

1. Istirahat yang cukup
2. Olahraga teratur
3. Meditasi
4. Mengembangkan hobi
5. Bersosialisasi dengan orang lain

Jika Anda merasa tertekan atau cemas, jangan ragu untuk berkonsultasi dengan ahli kesehatan mental. Meminta bantuan bukan tanda kelemahan, melainkan tanda bahwa Anda cukup kuat untuk mengakui keterbatasan diri.
`;

console.log(analyzeText(article));
```

## Customization

You can extend or modify the behavior of txtscan by importing and using the individual analysis modules:

```typescript
import { getSentiment } from '@sxyzdevv/txtscan/sentiment';
import { getReadability } from '@sxyzdevv/txtscan/readability';

// Custom text analysis
function myCustomAnalysis(text) {
  return {
    // Basic analysis
    sentiment: getSentiment(text),
    readability: getReadability(text),
    
    // Your custom metrics
    // ...
  };
}
```

## Roadmap

- [ ] Add support for more languages
- [ ] Improve sentiment analysis with machine learning
- [ ] Add text summarization feature
- [ ] Add topic modeling
- [ ] Support for entity recognition



## License

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

## Acknowledgments

- Inspired by various text analysis libraries and techniques
- Special thanks to contributors and the open-source community

---