Names to numbers: Difference between revisions

m
(julia example)
Line 836:
words = split(strip(txt), r"(\s+)|(\s*\-\s*)")
phrases, num, alph = Vector{Pair{Bool, Vector{String}}}(), false, false
for (i, word) in enumerate(words)
if isnumeric(word) && (num || word != "and")
if !num
Line 849:
push!(phrases, Pair(false, String[]))
num, alph = false, true
if length(phrases) > 1 && !occursin(r"\w", words[i - 1][end:end])
word = words[i - 1][end] * " " * word
end
end
push!(phrases[end][2], word)
Line 891 ⟶ 894:
end
end
return replace(join(outputphrases, " "), r"([\w\d])\s(\,|\:|\;|\.)" => s"\1\2")
end
4,107

edits