More work on repeated string summarization.

This commit is contained in:
Storm Dragon committed 2026-10-29 14:45:51 -04:00
1 parent 3cf41e662c
commit 47f18fdd28
7 files changed
+122 -34

No files matched your search

+4 -3
View File
@@ -159,8 +159,8 @@ func (p *Processor) Character(char rune) string {
// Text retains Python's levels and pause handling. At some and most, symbols
// embedded between letters or numbers are also named, except apostrophes in
// contractions and single numeric separators. Sentence punctuation still follows
// the selected level.
// contractions and single numeric separators. A percent sign after a digit is
// also named at some and most. Sentence punctuation follows the selected level.
func (p *Processor) Text(text, level string) string {
selected := p.levels[level]
var result strings.Builder
@@ -187,7 +187,8 @@ func (p *Processor) Text(text, level string) string {
}
}
_, known := p.symbols[char]
if selected[char] || embedded && known {
percentage := (level == "some" || level == "most") && char == '%' && index > 0 && unicode.IsDigit(chars[index-1])
if selected[char] || (embedded || percentage) && known {
result.WriteByte(' ')
result.WriteString(p.Character(char))
if strings.ContainsRune("',.;:?!", char) {