@sxyzdevv/txtscan
v0.0.6-rc
Published
module yang melakukan scanner kepada text yang anda berikan
Readme
@sxyzdevv/txtscan
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
# Using npm
npm install @sxyzdevv/txtscan
# Using yarn
yarn add @sxyzdevv/txtscan
# Using pnpm
pnpm add @sxyzdevv/txtscanQuick Start
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:
{
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 wordssentenceCount: Total number of sentencesparagraphCount: Total number of paragraphstopKeywords: Array of the 5 most frequently used meaningful wordssentiment: Sentiment classification ('positive', 'negative', or 'neutral')readability: Object containing readability metricsscore: Readability score (0-100)level: Readability level ('Mudah dibaca', 'Sedang', or 'Sulit dibaca')
Extended Example
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:
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
