Jump to content

Words containing "the" substring: Difference between revisions

Line 674:
thenDo:#transcribeCR</lang>
 
if counting per word is required (which is overkill here, as there are no duplicates in the file), keep them in a bag:
<lang smalltalk>bagOfWords := Bag new.
'unixdict.txt' asFilename contents
select:[:word | (word size > 11) and:[word includesString:'the' caseSensitive:trueOrFalseWhoKnows]]
thenDo:[:word | bagOfWords add:word. word transcribeCR].
 
bagOfWords transcribeCR</lang>
bagOfWords transcribeCR.
bagOfWords size transcribeCR</lang>
 
Note: #transcribeCR is a method in Object which says: "Transcript showCR:self".
Line 697 ⟶ 699:
<lang shell>chmod +x filter.st
./filter.st < unixdict.txt</lang>
{{out}}
authenticate
chemotherapy
chrysanthemum
...
weatherproof
weatherstrip
weatherstripping
 
Bag(chrysanthemum(*1) hydrothermal(*1) nevertheless(*1) chemotherapy(*1) eratosthenes(*1)
mathematician(*1) ... theoretician(*1) weatherbeaten(*1) weatherstripping(*1))
 
32
 
=={{header|Wren}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.