Skip to content

Repository files navigation

NarrowMind S2

Statistical Language Model for Intelligent Text Search & Analysis

Node.js License


🎯 What It Does

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Text      β”‚ --> β”‚   Language   β”‚ --> β”‚   Ranked    β”‚
β”‚   Corpus    β”‚     β”‚    Model     β”‚     β”‚  Sentences  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Multi-metric similarity scoring combining:

  • πŸ”€ TF-IDF - Term frequency analysis
  • πŸ“ Character-level - LCS-based matching
  • πŸ”— Co-occurrence - Semantic relationships

⚑ Quick Start

# 1. Clone & Install
git clone https://github.com/ItzmeJan/NarrowMind-L2.git
cd NarrowMind-L2

# 2. Add your text to input.txt
echo "Your text corpus here..." > input.txt

# 3. Run
node index.js
=> your query here

πŸ“Š Features

Feature Description
🧠 Multi-Metric Scoring TF-IDF + Character + Co-occurrence
πŸ” Semantic Analysis Word co-occurrence & n-gram patterns
βœ‚οΈ Text Processing Custom stemming & filler word filtering
πŸ“ˆ Interactive Shell Real-time query analysis

🎨 Usage

Interactive Mode

node index.js
======================================================================
  NarrowMind S2 - Statistical Language Model
======================================================================

=> where did aria walk

πŸ“Š QUERY ANALYSIS
  β€’ walked β†’ TF: 0.0180 | IDF: 3.0794
  β€’ aria β†’ TF: 0.0270 | IDF: 2.7918

πŸ”— Common Co-occurrences
  β€’ aria - co-occurs with 2 query tokens

πŸ“ˆ RANKING RESULTS
  1. [Score: 0.2639] β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
     "Aria walked home late after her evening class"

Programmatic

import { NarrowMindModel } from './model.js';

const model = new NarrowMindModel(textData);

// Rank sentences
const results = model.rankSentences(
    "your query",
    10,        // top N results
    0.70,      // TF-IDF weight
    0.10,      // Character weight
    false,     // filter fillers
    0.20,      // Co-occurrence weight
    'jaccard'  // method
);

βš™οΈ Configuration

Default Weights

TF-IDF:         β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 70%
Character:      β–ˆβ–ˆβ–ˆβ–ˆ 10%
Co-occurrence:  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 20%

Methods

  • Jaccard - Set-based similarity (intersection/union)
  • PMI - Pointwise Mutual Information

πŸ“ Structure

NarrowMind-L2/
β”œβ”€β”€ πŸš€ index.js       # Interactive shell
β”œβ”€β”€ 🧠 model.js       # Core language model
β”œβ”€β”€ βœ‚οΈ stem.js        # Stemming utility
β”œβ”€β”€ πŸ“‹ fillers.json   # Stop words
└── πŸ“„ input.txt      # Your corpus

πŸ”§ API

// Main methods
model.rankSentences(query, topN, ...weights)
model.getTokenStats(token)
model.getTopCoOccurrences(word, topN)
model.calculateCoOccurrenceScore(word1, word2, method)

πŸ“ˆ How It Works

1. Text Processing
   └─> Tokenize β†’ Stem β†’ Filter

2. Feature Extraction
   └─> TF-IDF vectors
   └─> Co-occurrence matrix
   └─> Character features

3. Similarity Calculation
   └─> Multi-metric scoring

4. Ranking
   └─> Weighted combination β†’ Results

πŸ“ License

ISC


Built with ❀️ for intelligent text understanding

Report Bug Β· Request Feature

About

Narrowmind JS version

Resources

Stars

46 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages