You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to write something that will flag if the same word is used twice in the same paragraph -- an echo word. I couldn't figure out a way to do this without using a tengo script, although I am option to suggestions.
I have a script that is working and returning the matches of all of the echo words, but Vale sometimes only flags one instance of each word. In VS Code, for example, only one instance of the repeated word "Leather." is underlined, when I want all of them to be. However, "times" are all underlined.
Any ideas on how I can get this working?
Text being used to test:
It was the best of times. It was the worst of times.
Red Leather. Yellow Leather.
Tengo Script (Including print statements that show that all matches are being caught/appended):
text := import("text")
fmt := import("fmt")
document := text.to_lower(scope)
words := text.fields(document)
seen := {}
matches := []
fmt.println("document: ", document)
for word in words {
if seen[word] != undefined && text.count(document, word) > 1 {
match_arry := text.re_find(word, document, text.count(document, word))
fmt.println("(match_arry)", match_arry)
for match_group in match_arry {
match_obj := match_group[0] // Get the map with 'text', 'begin', 'end'
begin := match_obj["begin"]
end := match_obj["end"]
matches = append(matches, {begin: begin, end: end})
}
} else {
seen[word] = true
}
}
fmt.println("matches: ", matches)
Script Output with JSON vale output. This is what happens when I run it -- my debugging statments print and I get what vale is flagging, but it is only one example of each word:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am attempting to write something that will flag if the same word is used twice in the same paragraph -- an echo word. I couldn't figure out a way to do this without using a tengo script, although I am option to suggestions.
I have a script that is working and returning the matches of all of the echo words, but Vale sometimes only flags one instance of each word. In VS Code, for example, only one instance of the repeated word "Leather." is underlined, when I want all of them to be. However, "times" are all underlined.

Any ideas on how I can get this working?
Text being used to test:
Rule:
Tengo Script (Including print statements that show that all matches are being caught/appended):
Script Output with JSON vale output. This is what happens when I run it -- my debugging statments print and I get what vale is flagging, but it is only one example of each word:
Beta Was this translation helpful? Give feedback.
All reactions