Score separator quality (higher is better)
(sep rune, count int)
| 169 | |
| 170 | // Score separator quality (higher is better) |
| 171 | func (sd *sepDetecor) scoreSeparator(sep rune, count int) int { |
| 172 | score := 0 |
| 173 | |
| 174 | // Prefer common separators |
| 175 | switch sep { |
| 176 | case ',': |
| 177 | score += 1000 // Highest priority |
| 178 | case '\t': |
| 179 | score += 900 |
| 180 | case '|': |
| 181 | score += 800 |
| 182 | case ';': |
| 183 | score += 700 |
| 184 | case ':': |
| 185 | score += 600 |
| 186 | case ' ': |
| 187 | score += 100 // Lowest priority (can be ambiguous) |
| 188 | default: |
| 189 | score += 500 // Moderate priority for other chars |
| 190 | } |
| 191 | |
| 192 | // Prefer separators with reasonable column counts (2-100) |
| 193 | if count >= 2 && count <= 100 { |
| 194 | score += count * 10 |
| 195 | } else if count > 100 { |
| 196 | score -= 100 // Penalize too many columns |
| 197 | } |
| 198 | |
| 199 | return score |
| 200 | } |
| 201 | |
| 202 | // remove duplication item in []rune |
| 203 | func uniqueChar(intSlice []rune) []rune { |
no outgoing calls