>>> ?
>>>
>>> ?c ? h wcIterative fname
>>> ? ??;D;WL;idx;len;word;wc;wcl;idx
>>> ? ?? Return ?-sorted count of unique words in
string
>>> vector D, ignoring case and punctuation
>>> ? ?? @param h(?) - how many top word counts to
return
>>> ? ?? @param D(?) - vector of words
>>> ?
>>> ? D ? lowerAndStrip (?fio['read_file'] fname)
?? raw
>>> text with newlines
>>> ? timeStart ? timeMs
>>> ? D ? (~ D ? ' ') ? D ? make into a vector of
words
>>> ? WL ? ?D
>>> ? ??#DEBUG# ? ? 'unique words:',WL
>>> ? wcl ? 0?0
>>> ? idx ? 1
>>> ? len ? ?WL
>>> count:
>>> ? ??#DEBUG# ? ? idx
>>> ? ?(idx>len)/done
>>> ? word ? ?idx?WL
>>> ? ??#DEBUG# ? ? word
>>> ? wc ? +/(word??D)
>>> ? wcl ? wcl,wc
>>> ? ??#DEBUG# ? ? wcl
>>> ? idx ? 1+idx
>>> ? ? count
>>> done:
>>> ? c ? h?[2] (WL)[?wcl],[0.5]wcl[?wcl]
>>> ? timeEnd ? timeMs
>>> ? ? ? 'Time:',(timeEnd-timeStart),'ms'
>>> ?
>>>
>>> ?r ? n wcOuterProd fname
>>> ? ?? ;D;wl;uniqwords;wordcounts;sortOrder
>>> ? D ? lowerAndStrip (?fio['read_file'] fname)
?? raw
>>> text with newlines
>>> ? timeStart ? timeMs
>>> ? wl ? (~ D ? ' ') ? D
>>> ? ??#DEBUG# ? ? '? wl:', ? wl
>>> ? uniqwords ? ?wl
>>> ? ??#DEBUG# ? ? '? uniqwords:', ? uniqwords
>>> ? wordcounts ? +?(wl ?.? uniqwords)
>>> ? sortOrder ? ?wordcounts
>>> ? r ? n?[2]
>>> uniqwords[sortOrder],[0.5]wordcounts[sortOrder]
>>> ? timeEnd ? timeMs
>>> ? ? ? 'Time:',(timeEnd-timeStart),'ms'
>>> ?
>>>
>>>
>>
>
--
Subject: Digest Footer
___
Bug-apl mailing list
Bug-apl@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-apl
--
End of Bug-apl Digest, Vol 99, Issue 13
***
t of course that
> >>> complicates the algorithm.
> >>>
> >>> [my 'outer product' and 'iterative' versions of the
> >>> code are below]
> >>>
> >>> Thanks,
> >>> -Russ
> >>>
> >>> ---
> >>> #!/usr/local/bin/apl --script
> >>>
> ?
> >>> ? ??
> >>> ? wordcount.apl ? ? ?2021-12-26 ?20:07:07 (GMT-8) ??
> >>> ? ??
> >>>
> ?
> >>>
> >>> ? function edif has ufun1 pointer 0!
> >>>
> >>> ?r ? timeMs; t
> >>> ? t ? ?TS
> >>> ? r ?
> >>> (((t[3]?86400)+(t[4]?3600)+(t[5]?60)+(t[6]))?1000)+t[7]
> >>> ?
> >>>
> >>> ?r ? lowerAndStrip s;stripped;mixedCase
> >>> ?stripped ? '
> >>> abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz*'
> >>> ?mixedCase ? ?av[11],'
> >>>
> ,.?!;:"''()[]-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
> >>> ?r ? stripped[mixedCase ? s]
> >>> ?
> >>>
> >>> ?c ? h wcIterative fname
> >>> ? ??;D;WL;idx;len;word;wc;wcl;idx
> >>> ? ?? Return ?-sorted count of unique words in string
> >>> vector D, ignoring case and punctuation
> >>> ? ?? @param h(?) - how many top word counts to return
> >>> ? ?? @param D(?) - vector of words
> >>> ?
> >>> ? D ? lowerAndStrip (?fio['read_file'] fname) ?? raw
> >>> text with newlines
> >>> ? timeStart ? timeMs
> >>> ? D ? (~ D ? ' ') ? D ? make into a vector of words
> >>> ? WL ? ?D
> >>> ? ??#DEBUG# ? ? 'unique words:',WL
> >>> ? wcl ? 0?0
> >>> ? idx ? 1
> >>> ? len ? ?WL
> >>> count:
> >>> ? ??#DEBUG# ? ? idx
> >>> ? ?(idx>len)/done
> >>> ? word ? ?idx?WL
> >>> ? ??#DEBUG# ? ? word
> >>> ? wc ? +/(word??D)
> >>> ? wcl ? wcl,wc
> >>> ? ??#DEBUG# ? ? wcl
> >>> ? idx ? 1+idx
> >>> ? ? count
> >>> done:
> >>> ? c ? h?[2] (WL)[?wcl],[0.5]wcl[?wcl]
> >>> ? timeEnd ? timeMs
> >>> ? ? ? 'Time:',(timeEnd-timeStart),'ms'
> >>> ?
> >>>
> >>> ?r ? n wcOuterProd fname
> >>> ? ?? ;D;wl;uniqwords;wordcounts;sortOrder
> >>> ? D ? lowerAndStrip (?fio['read_file'] fname) ?? raw
> >>> text with newlines
> >>> ? timeStart ? timeMs
> >>> ? wl ? (~ D ? ' ') ? D
> >>> ? ??#DEBUG# ? ? '? wl:', ? wl
> >>> ? uniqwords ? ?wl
> >>> ? ??#DEBUG# ? ? '? uniqwords:', ? uniqwords
> >>> ? wordcounts ? +?(wl ?.? uniqwords)
> >>> ? sortOrder ? ?wordcounts
> >>> ? r ? n?[2]
> >>> uniqwords[sortOrder],[0.5]wordcounts[sortOrder]
> >>> ? timeEnd ? timeMs
> >>> ? ? ? 'Time:',(timeEnd-timeStart),'ms'
> >>> ?
> >>>
> >>>
> >>
> >
>
>
>
>
> --
>
> Subject: Digest Footer
>
> ___
> Bug-apl mailing list
> Bug-apl@gnu.org
> https://lists.gnu.org/mailman/listinfo/bug-apl
>
>
> --
>
> End of Bug-apl Digest, Vol 99, Issue 13
> ***
>