---
title: classifier | CodeWeaver Docs
description: API reference for codeweaver.semantic.classifier
url: "https://docs.knitli.com/api/semantic/classifier"
type: static
generatedAt: "2026-04-17T17:21:09.554Z"
---

# classifier
       [Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F.%20I%20want%20to%20ask%20questions%20about%20it.)[View in Markdown](/codeweaver/api/semantic/classifier.md)       [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F)[Share on X](https://x.com/intent/tweet?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F&text=classifier)[Share on Threads](https://threads.net/intent/post?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F&text=classifier)[Share on Bluesky](https://bsky.app/intent/compose?text=classifier%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F)[Share on Reddit](https://reddit.com/submit?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F&title=classifier)[Share on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F&t=classifier)[Share on Email](mailto:?subject=classifier&body=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F)[Share on WhatsApp](https://wa.me/?text=classifier%20https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F)[Share on Telegram](https://t.me/share/url?url=https%3A%2F%2Fdocs.knitli.com%2Fcodeweaver%2Fapi%2Fsemantic%2Fclassifier%2F&text=classifier)
# `codeweaver.semantic.classifier`
[Section titled “codeweaver.semantic.classifier”](#codeweaversemanticclassifier)
Grammar-based semantic node classification using inherent tree-sitter structure.

This module provides primary classification by leveraging the explicit semantic relationships encoded in node_types.json files:

 - Categories → Abstract groupings (was: Subtypes/Abstract types)
 - DirectConnections → Structural relationships with semantic Roles (was: Fields)
 - PositionalConnections → Ordered relationships without Roles (was: Children)
 - can_be_anywhere → Syntactic elements that can appear anywhere (was: Extra)

## Class: `ClassificationMethod`
[Section titled “Class: ClassificationMethod”](#class-classificationmethod)
Enumeration of classification methods.

## Class: `EvidenceKind`
[Section titled “Class: EvidenceKind”](#class-evidencekind)
Kinds of evidence used for classifying Things.

An int-enum for easy comparison of evidence strength. Higher numbers indicate stronger evidence. The confidence score is estimated based on the combined strength of the evidence kinds used.

### Method: `confidence`
[Section titled “Method: confidence”](#method-confidence)

**

```
confidence()
```

Estimate confidence score based on the kinds of evidence used.

Args: kinds: List of EvidenceKind values used in classification.

Returns: Confidence score from 0.0 to 1.0

### Method: `evidence_summary`
[Section titled “Method: evidence_summary”](#method-evidence_summary)

**

```
evidence_summary()
```

Generate a human-readable summary of the evidence kinds used.

Args: kinds: List of EvidenceKind values used in classification.

Returns: Human-readable summary of the evidence kinds.

## Class: `GrammarBasedClassifier`
[Section titled “Class: GrammarBasedClassifier”](#class-grammarbasedclassifier)
Primary classifier using grammar structure from node_types.json.

### Method: `classify_thing`
[Section titled “Method: classify_thing”](#method-classify_thing)

**

```
classify_thing()
```

Classify a thing using grammar structure.

Classification pipeline (highest to lowest confidence): very high confidence:

 1. Known exceptions (e.g., comments)
 1. can_be_anywhere Things (mostly comments, but small number and all known)
 1. Token purpose classification (very high confidence)
 1. Multi-tier Thing classification for specific language-category pairs (e.g., Ruby primary, Rust declaration_statement)
 1. Category-based classification for other categories

medium-high confidence: 6. Direct connections analysis (medium confidence)

lower confidence: 7. Cross-language lookup (lowest confidence, fallback only) — looks for same-named Things in other languages with high-confidence classifications. It generally works but because of language differences, confidence is lower. Can still produce high confidence results if multiple other languages agree on classification.

Args: thing_name: The Thing name (e.g., “function_definition”) language: The programming language

Returns: Classification result with confidence, or None if classification not possible

## Class: `GrammarClassificationResult`
[Section titled “Class: GrammarClassificationResult”](#class-grammarclassificationresult)
Result of grammar-based classification.

Attributes: classification: Semantic classification assigned to the thing rank: Semantic rank (importance level) classification_method: Method used for classification evidence: Kinds of evidence used for classification evidence_summary: Human-readable explanation of classification reasoning confidence: Confidence score (0.0-1.0)

### Method: `evidence_summary`
[Section titled “Method: evidence_summary”](#method-evidence_summary-1)

**

```
evidence_summary()
```

Human-readable summary of the evidence kinds used.

### Method: `from_results`
[Section titled “Method: from_results”](#method-from_results)

**

```
from_results()
```

Combine multiple classification results into a single result.

Args: results: List of GrammarClassificationResult instances to combine.

Returns: Combined GrammarClassificationResult with highest confidence, or None if no results.

### Method: `is_confident`
[Section titled “Method: is_confident”](#method-is_confident)

**

```
is_confident()
```

Whether the confidence level is above the threshold.

## Function: `is_composite_thing`
[Section titled “Function: is_composite_thing”](#function-is_composite_thing)

**

```
is_composite_thing()
```

Type guard to check if a Thing is a CompositeThing.

## Function: `is_token`
[Section titled “Function: is_token”](#function-is_token)

**

```
is_token()
```

Type guard to check if a Thing is a Token.