Metadata-Version: 2.4
Name: cognitive-signal
Version: 0.1.1
Summary: Orthogonal cognitive signal extraction and pattern detection from journal entries. Extracts valence, arousal, agency, self-focus, social orientation, and action ratio as independent signals, then discovers temporal trends, semantic drift, latent psychological states, and structural change points.
Author: Sneha Prajapati
License: MIT
Project-URL: Homepage, https://github.com/snehaprajapati/cognitive-signal
Project-URL: Repository, https://github.com/snehaprajapati/cognitive-signal
Project-URL: Issues, https://github.com/snehaprajapati/cognitive-signal/issues
Keywords: cognitive-modeling,nlp,signal-extraction,journal-analysis,sentiment-analysis,hidden-markov-model,change-point-detection,mental-health,psychology
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: scikit-learn>=1.2
Requires-Dist: sentence-transformers>=2.2
Requires-Dist: spacy>=3.5
Requires-Dist: vaderSentiment>=3.3
Requires-Dist: hmmlearn>=0.3
Requires-Dist: ruptures>=1.1
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.1; extra == "dev"
Provides-Extra: eval
Requires-Dist: tabulate>=0.9; extra == "eval"
Dynamic: license-file

# cognitive-signal

Extract orthogonal cognitive signals from journal entries.

## Installation

```bash
pip install cognitive-signal
```

Download the spaCy model:

```bash
python -m spacy download en_core_web_sm
```

## Quick Start

```python
from datetime import datetime
from cognitive_signal import SignalDetectionPipeline, JournalEntry

# Create journal entries
entries = [
    JournalEntry(
        text="I felt empowered today. Made a big decision at work.",
        timestamp=datetime(2024, 1, 1),
        entry_id="1"
    ),
    JournalEntry(
        text="Worried about the consequences. Maybe I was too hasty.",
        timestamp=datetime(2024, 1, 2),
        entry_id="2"
    ),
    JournalEntry(
        text="Talked to my team and we aligned on the approach.",
        timestamp=datetime(2024, 1, 3),
        entry_id="3"
    ),
]

# Run the pipeline
pipeline = SignalDetectionPipeline()
result = pipeline.process_journal(entries)

# Access signal values
for entry_id, signal in result.signals.items():
    print(f"Entry {entry_id}:")
    print(f"  Valence: {signal.valence:.2f}")
    print(f"  Arousal: {signal.arousal:.2f}")
    print(f"  Agency: {signal.agency:.2f}")

# Temporal trends
for signal_name, trend in result.temporal_trends.items():
    print(f"{signal_name}: slope={trend.slope:.3f}, direction={trend.direction}")

# HMM states
print(f"States: {result.segmentation.states}")
print(f"Phases: {result.segmentation.phases}")

# Change points
for cp in result.change_points:
    print(f"Change at index {cp.index}: {cp.signals_changed}")
```

## The 7 Signals

| Signal | Description |
|--------|-------------|
| **Valence** | Emotional polarity from negative (-1) to positive (+1) |
| **Arousal** | Activation level from calm (0) to excited (1) |
| **Agency** | Internal locus of control vs. external attribution |
| **Self-Focus** | First-person singular pronoun density |
| **Social Orientation** | References to others and relationships |
| **Temporal Orientation** | Focus on past, present, or future |
| **Action Ratio** | Verb density indicating action vs. reflection |

## Processing Layers

1. **Signal Extraction** - Extract 7 orthogonal cognitive signals from raw text
2. **Temporal Analysis** - Detect trends, slopes, and momentum in signals over time
3. **Semantic Motion** - Track drift in embedding space and identify thematic shifts
4. **HMM Segmentation** - Discover latent psychological states using Hidden Markov Models
5. **Change Point Detection** - Identify structural breaks in signal patterns

### Layer 1.5: Dissonance Detection

Between signal extraction and temporal analysis, dissonance detection identifies contradictions:

- **Valence-Agency Dissonance**: Positive emotions but low agency (or vice versa)
- **Self-Social Dissonance**: High self-focus combined with high social orientation
- **Temporal Dissonance**: Conflicting temporal orientations within same entry
- **Action-Reflection Dissonance**: High action words but reflective/uncertain tone

## License

MIT
