| name | complexity-scorer-5-confidence-scoring |
| description | Sub-skill of complexity-scorer: 5. Confidence Scoring (+1). |
| version | 1.0.0 |
| category | _core |
| type | reference |
| scripts_exempt | true |
5. Confidence Scoring (+1)
5. Confidence Scoring
Add confidence to scoring:
#!/bin/bash
calculate_confidence() {
local text="$1"
local confidence=50
local word_count=$(echo "$text" | wc -w)
local keyword_matches=0
local text_lower=$(echo "$text" | tr '[:upper:]' '[:lower:]')
if [[ $word_count -gt 15 ]]; then
((confidence+=20))
elif [[ $word_count -gt 8 ]]; then
((confidence+=10))
elif [[ $word_count -lt 3 ]]; then
((confidence-=20))
fi
for pattern in "$HIGH_COMPLEXITY" "$MEDIUM_COMPLEXITY" "$LOW_COMPLEXITY"; do
if echo "$text_lower" | grep -qE "$pattern"; then
((keyword_matches++))
fi
done
((confidence += keyword_matches * 10))
[[ $confidence -gt 100 ]] && confidence=100
[[ $confidence -lt 10 ]] && confidence=10
echo $confidence
}
confidence_label() {
local confidence="$1"
if [[ $confidence -ge 80 ]]; then
echo "High"
elif [[ $confidence -ge 60 ]]; then
echo "Medium"
elif [[ $confidence -ge 40 ]]; then
echo "Low"
else
echo "Very Low"
fi
}
6. Historical Learning
Adjust based on past accuracy:
#!/bin/bash
HISTORY_FILE="${HOME}/.complexity-scorer/history.log"
log_outcome() {
local task="$1"
local predicted_score="$2"
local actual_complexity="$3"
local timestamp=$(date '+%Y-%m-%d_%H:%M:%S')
mkdir -p "$(dirname "$HISTORY_FILE")"
echo "${timestamp}|${predicted_score}|${actual_complexity}|${task}" >> "$HISTORY_FILE"
}
calculate_accuracy() {
local correct=0
local total=0
while IFS='|' read -r ts predicted actual task; do
[[ "$ts" =~ ^#.*$ ]] && continue
[[ -z "$ts" ]] && continue
((total++))
local predicted_class=$(classify_complexity )
[[ == ]];
((correct++))
<
[[ -gt 0 ]];
$((correct * / total))
0
}
() {
IFS= -r ts predicted actual task;
predicted_class=$(classify_complexity )
[[ != ]];
<
}