Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #49326 > unrolled thread
| Started by | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| First post | 2016-07-22 14:24 +0000 |
| Last post | 2016-07-22 14:24 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.forth
Counting words "WJ" <w_a_x_man@yahoo.com> - 2016-07-22 14:24 +0000
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2016-07-22 14:24 +0000 |
| Subject | Counting words |
| Message-ID | <nmtab9$v38$1@dont-email.me> |
Count occurrences of words in "Alice's Adventures in Wonderland":
R:
filename = "Alice.txt"
rx = "[^a-zA-Z]+"
sub( paste0("^",rx), "", readChar(filename, 999000)) -> text.of.file
words <- (strsplit(text.of.file, rx))[[1]]
stats = summary( factor(words), maxsum = 99000)
> stats[1:8]
a A abide able about About above absence
672 18 2 1 101 1 3 1
> tail(stats,8)
YOUR yours YOURS yourself youth Zealand zigzag zip
7 2 1 10 6 1 1 1
Show the most common words of sizes 10 through 16:
for (i in 10:16)
{ word = sort(stats[nchar(names(stats)) == i], decreasing=TRUE)[1]
cat("size:", i, " word:", names(word), "\n")
}
size: 10 word: electronic
size: 11 word: Caterpillar
size: 12 word: conversation
size: 13 word: uncomfortable
size: 14 word: contemptuously
size: 15 word: MERCHANTIBILITY
size: 16 word: unenforceability
Can it be more concise and readable in Forth?
--
3/28/14 - Silas Nelson, 1, was beaten to death in Olyphant, PA. His mother's
black boyfriend was charged.
10/12/14 - Li'Asia Moorer, 2, was tortured and beaten to death in Cleveland,
OH. The victim's mother's black boyfriend has been charged.
http://conservative-headlines.com/2015/01/55690/
Back to top | Article view | comp.lang.forth
csiph-web