๐Ÿฆ†

Navigation

๐Ÿง‘โ€๐Ÿฆฏ โฎŸ

Do - Listen, Process, Act & Learn

This section is about the brain of the operation.
The Natural Language Processor.

Key Features

Pattern Matching Engine

Dual-layer system with pre-compiled regex for exact matches and Levenshtein-based fuzzy matching as fallback.

Automatic parameter extraction and 15% tolerance threshold for natural input errors.

Supports command chaining by splitting patterns with pre-defined word in the module option.

Declarative Pattern Definition

All command patterns and variants defined in Nix.

Build-time pattern expansion eliminates runtime regex compilation.

Prioritization by weight, complexity, and lexicographic order.

Signature-Based Fuzzy Index

Pre-computed, word-orderโ€“independent signatures for accelerated fuzzy lookup.

Optimized for large-scale command sets and voice variations.

Parameter & Entity System

Supports required, alternative, and optional parameters.

Entity resolution maps natural phrases to canonical flags or arguments.

Three Parameter Types:

{param} - Required parameters with entity resolution

(option1|option2) - Required alternative

[optional|words] - Optional components

Extensive Sentence Testing Framework

Generates test cases by expanding sentence patterns with optional words and alternatives.

Validates both exact and fuzzy matching against defined voice commands.

Verifies command recognition accuracy, handles parameter extraction, and provides detailed statistics about voice command coverage and performance.

Conflict-Free Validation

Build-time assertion checks prevent overlapping or ambiguous sentence definitions.

Detects prefix and duplicate conflicts before deployment.

Statistical Learning

Tracks match success rates, fuzzy distance effectiveness, and failure patterns.

Feeds data back into model tuning and pattern optimization.

Real-Time Voice Mode

Rust-based WebSocket client handles live transcription and NLP intent recognition.

Enables hands-free interaction and compound command handling.

The Brain of the Voice Assistant

The natural language processor is the brain of my dotfiles.
It translates human text into Shell commands.
It began in Bash as a world-class challenge, worked flawlessly - until my /bin grew.
Now it's in Rust and faster than ever.
User defines sentences in Nix, and at build time it dynamically generates regex patterns.
At runtime it automatically resolves entities to properly generate the parameters before execution.

What Does All THis Mean?

It means that I can say for example:

"Update the flake and rebuild the system and deploy dad's media server and wait 5 minutes and check for errors at dad's media server"

โฎž but does it understand ducks?? quack quack quack quack quack quack quack

Another usage example:

"play the movie the mighty ducks"

โฎž View 'play the movie the mighty ducks' Usage
        
๐Ÿฆ†๐Ÿ   HOME via ๎œ˜ via ๐Ÿ v3.12.10 via ๐Ÿฆ€ v1.86.0
:41:04 โฏ yo do "spela upp filmen the mighty ducks"
[๐Ÿฆ†๐Ÿ“œ] [19:41:11] โœ…INFOโœ… โฎž [๐Ÿฆ†๐Ÿง ] 'spela upp filmen the mighty ducks"
[๐Ÿฆ†๐Ÿ“œ] โœ…INFOโœ… โฎž MEMORY ADJUSTMENT: tv: base=3 โ†’ adjusted=0 (uses=5, confirms=1, context=YES)
[๐Ÿฆ†๐Ÿ“œ] โœ…INFOโœ… โฎž MEMORY ADJUSTMENT: tv-guide: base=3 โ†’ adjusted=3 (uses=0, confirms=0, context=NO)
[๐Ÿฆ†๐Ÿ“œ] โœ…INFOโœ… โฎž MEMORY ADJUSTMENT: call-remote: base=3 โ†’ adjusted=3 (uses=0, confirms=0, context=NO)
๐Ÿฆ†MEMORY:ARGS:--typ movie --search the mighty ducks
๐Ÿฆ†MEMORY:SENTENCE:spela upp {typ} {search}
๐Ÿฆ†MEMORY:TYPE:exact
   โ”Œโ”€(yo-tv)
   โ”‚๐Ÿฆ† qwack!? spela upp {typ} {search}
   โ””โ”€โฎž --typ movie
   โ””โ”€โฎž --search the mighty ducks
   โ””โ”€โฐ do took 23.914604ms
Playlist generated: /Pool/playlist.m3u (shuffle: true)
๐Ÿฆ† Recorded: tv - spela upp {typ} {search}

Adding an extra command after a sucessful match by saying:
"Good job!"
Would give an manual confirmation, boosting the match in the future.

โฎž qwaack?! datz qwacktastic!!1


Configuring the NLP

There is not much to configure really, but there are a couple of settings that enhance the user experience.

โฎž View Available NLP configuration

{ # ๐Ÿฆ† duck say โฎž yo! letz configure the natural language processor!
  config,
  lib,
  pkgs,
  ...
} : let
in { # ๐Ÿฆ†saysโฎžqwack
  yo = {
    # ๐Ÿฆ†saysโฎž when no match is found TTS will pick a random phrases from the list
    sorryPhrases = [ 
      "Sorry I couldn't understand that"
      "Please repeat that"
    ]; # ๐Ÿฆ†saysโฎž these wordz letz u chain commands
    SplitWords = [ "also" ];

  }:} 

Table of Content:

Developing a feature rich NLP with jq, Nix & Bash
Making Good Use of the Combinational Explosion Requires Top Tier Speed - Porting to Rust
(WIP)Memory - Context-Aware & Self-Learning Voice Assistant
Sentence Validation - Rapid Fast Testing Framework