MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / score_code_markers

Function score_code_markers

uncommon_route/router/structural.py:124–132  ·  view source on GitHub ↗

Code presence via bracket/semicolon density + fenced blocks.

(text: str)

Source from the content-addressed store, hash-verified

122
123
124def score_code_markers(text: str) -> DimensionScore:
125 """Code presence via bracket/semicolon density + fenced blocks."""
126 char_hits = sum(1 for ch in text if ch in _CODE_CHARS)
127 char_density = char_hits / max(len(text), 1)
128 has_fenced_block = text.count("```") >= 2
129
130 score = min(1.0, char_density * 8.0 + (0.4 if has_fenced_block else 0.0))
131 signal = "code" if score > 0.2 else None
132 return DimensionScore("code_markers", score, signal)
133
134
135def score_math_symbols(text: str) -> DimensionScore:

Callers 2

estimate_output_budgetFunction · 0.85

Calls 2

DimensionScoreClass · 0.90
countMethod · 0.45

Tested by

no test coverage detected