Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,20 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Letter_Frequency is
|
||||
Counters: array (Character) of Natural := (others => 0); -- initialize all Counters to 0
|
||||
C: Character;
|
||||
File: Ada.Text_IO.File_Type;
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Open(File, Mode => Ada.Text_IO.In_File, Name => "letter_frequency.adb");
|
||||
while not Ada.Text_IO.End_Of_File(File) loop
|
||||
Ada.Text_IO.Get(File, C);
|
||||
Counters(C) := Counters(C) + 1;
|
||||
end loop;
|
||||
|
||||
for I in Counters'Range loop
|
||||
if Counters(I) > 0 then
|
||||
Ada.Text_IO.Put_Line("'" & I & "':" & Integer'Image(Counters(I)));
|
||||
end if;
|
||||
end loop;
|
||||
end Letter_Frequency;
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
Func _Letter_frequency($Path, $fcase = True, $fspecial_chars = True)
|
||||
Local $hFile, $sRead, $iupto, $iStart, $iCount
|
||||
If Not $fcase Then $fcase = False
|
||||
If Not $fspecial_chars Then
|
||||
$iStart = 64
|
||||
If Not $fcase Then
|
||||
$iupto = 26
|
||||
Else
|
||||
$iupto = 58
|
||||
EndIf
|
||||
Else
|
||||
$iStart = 31
|
||||
$iupto = 224
|
||||
EndIf
|
||||
$hFile = FileOpen($Path, 0)
|
||||
$sRead = FileRead($hFile)
|
||||
FileClose($hFile)
|
||||
For $i = 1 To $iupto
|
||||
If Not $fspecial_chars Then
|
||||
If $iStart + $i > 90 And $iStart + $i < 97 Then ContinueLoop
|
||||
EndIf
|
||||
$sRead = StringReplace($sRead, Chr($iStart + $i), "", 0, $fcase)
|
||||
$iCount = @extended
|
||||
If $iCount > 0 Then ConsoleWrite(Chr($iStart + $i) & " : " & $iCount & @CRLF)
|
||||
Next
|
||||
EndFunc ;==>_Letter_frequency
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Letter-Frequency.
|
||||
AUTHOR. Bill Gunshannon.
|
||||
INSTALLATION. Home.
|
||||
DATE-WRITTEN. 12 December 2021.
|
||||
************************************************************
|
||||
** Program Abstract:
|
||||
** A rather simplistic program to do the kind of thing
|
||||
** that COBOL does really well.
|
||||
************************************************************
|
||||
|
||||
ENVIRONMENT DIVISION.
|
||||
|
||||
INPUT-OUTPUT SECTION.
|
||||
FILE-CONTROL.
|
||||
SELECT Text-File ASSIGN TO "File.txt"
|
||||
ORGANIZATION IS LINE SEQUENTIAL.
|
||||
|
||||
DATA DIVISION.
|
||||
|
||||
FILE SECTION.
|
||||
|
||||
FD Text-File
|
||||
DATA RECORD IS Record-Name.
|
||||
01 Record-Name PIC X(80).
|
||||
|
||||
|
||||
WORKING-STORAGE SECTION.
|
||||
|
||||
01 Eof PIC X VALUE 'F'.
|
||||
|
||||
01 Letter-cnt.
|
||||
05 A-cnt PIC 9(5) VALUE 0.
|
||||
05 B-cnt PIC 9(5) VALUE 0.
|
||||
05 C-cnt PIC 9(5) VALUE 0.
|
||||
05 D-cnt PIC 9(5) VALUE 0.
|
||||
05 E-cnt PIC 9(5) VALUE 0.
|
||||
05 F-cnt PIC 9(5) VALUE 0.
|
||||
05 G-cnt PIC 9(5) VALUE 0.
|
||||
05 H-cnt PIC 9(5) VALUE 0.
|
||||
05 I-cnt PIC 9(5) VALUE 0.
|
||||
05 J-cnt PIC 9(5) VALUE 0.
|
||||
05 K-cnt PIC 9(5) VALUE 0.
|
||||
05 L-cnt PIC 9(5) VALUE 0.
|
||||
05 M-cnt PIC 9(5) VALUE 0.
|
||||
05 N-cnt PIC 9(5) VALUE 0.
|
||||
05 O-cnt PIC 9(5) VALUE 0.
|
||||
05 P-cnt PIC 9(5) VALUE 0.
|
||||
05 Q-cnt PIC 9(5) VALUE 0.
|
||||
05 R-cnt PIC 9(5) VALUE 0.
|
||||
05 S-cnt PIC 9(5) VALUE 0.
|
||||
05 T-cnt PIC 9(5) VALUE 0.
|
||||
05 U-cnt PIC 9(5) VALUE 0.
|
||||
05 V-cnt PIC 9(5) VALUE 0.
|
||||
05 W-cnt PIC 9(5) VALUE 0.
|
||||
05 X-cnt PIC 9(5) VALUE 0.
|
||||
05 Y-cnt PIC 9(5) VALUE 0.
|
||||
05 Z-cnt PIC 9(5) VALUE 0.
|
||||
|
||||
01 Letter-disp.
|
||||
05 A-cnt PIC ZZZZ9.
|
||||
05 B-cnt PIC ZZZZ9.
|
||||
05 C-cnt PIC ZZZZ9.
|
||||
05 D-cnt PIC ZZZZ9.
|
||||
05 E-cnt PIC ZZZZ9.
|
||||
05 F-cnt PIC ZZZZ9.
|
||||
05 G-cnt PIC ZZZZ9.
|
||||
05 H-cnt PIC ZZZZ9.
|
||||
05 I-cnt PIC ZZZZ9.
|
||||
05 J-cnt PIC ZZZZ9.
|
||||
05 K-cnt PIC ZZZZ9.
|
||||
05 L-cnt PIC ZZZZ9.
|
||||
05 M-cnt PIC ZZZZ9.
|
||||
05 N-cnt PIC ZZZZ9.
|
||||
05 O-cnt PIC ZZZZ9.
|
||||
05 P-cnt PIC ZZZZ9.
|
||||
05 Q-cnt PIC ZZZZ9.
|
||||
05 R-cnt PIC ZZZZ9.
|
||||
05 S-cnt PIC ZZZZ9.
|
||||
05 T-cnt PIC ZZZZ9.
|
||||
05 U-cnt PIC ZZZZ9.
|
||||
05 V-cnt PIC ZZZZ9.
|
||||
05 W-cnt PIC ZZZZ9.
|
||||
05 X-cnt PIC ZZZZ9.
|
||||
05 Y-cnt PIC ZZZZ9.
|
||||
05 Z-cnt PIC ZZZZ9.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
|
||||
Main-Program.
|
||||
OPEN INPUT Text-File
|
||||
PERFORM UNTIL Eof = 'T'
|
||||
READ Text-File
|
||||
AT END MOVE 'T' to Eof
|
||||
END-READ
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING A-cnt OF Letter-cnt FOR ALL 'A'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING B-cnt OF Letter-cnt FOR ALL 'B'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING C-cnt OF Letter-cnt FOR ALL 'C'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING D-cnt OF Letter-cnt FOR ALL 'D'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING E-cnt OF Letter-cnt FOR ALL 'E'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING F-cnt OF Letter-cnt FOR ALL 'F'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING G-cnt OF Letter-cnt FOR ALL 'G'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING H-cnt OF Letter-cnt FOR ALL 'H'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING I-cnt OF Letter-cnt FOR ALL 'I'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING J-cnt OF Letter-cnt FOR ALL 'J'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING K-cnt OF Letter-cnt FOR ALL 'K'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING L-cnt OF Letter-cnt FOR ALL 'L'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING M-cnt OF Letter-cnt FOR ALL 'M'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING N-cnt OF Letter-cnt FOR ALL 'N'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING O-cnt OF Letter-cnt FOR ALL 'O'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING P-cnt OF Letter-cnt FOR ALL 'P'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING Q-cnt OF Letter-cnt FOR ALL 'Q'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING R-cnt OF Letter-cnt FOR ALL 'R'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING S-cnt OF Letter-cnt FOR ALL 'S'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING T-cnt OF Letter-cnt FOR ALL 'T'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING U-cnt OF Letter-cnt FOR ALL 'U'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING V-cnt OF Letter-cnt FOR ALL 'V'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING W-cnt OF Letter-cnt FOR ALL 'W'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING X-cnt OF Letter-cnt FOR ALL 'X'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING Y-cnt OF Letter-cnt FOR ALL 'Y'
|
||||
INSPECT FUNCTION UPPER-CASE(Record-Name)
|
||||
TALLYING Z-cnt OF Letter-cnt FOR ALL 'Z'
|
||||
END-PERFORM.
|
||||
CLOSE Text-File.
|
||||
MOVE CORRESPONDING Letter-cnt To Letter-disp.
|
||||
DISPLAY 'Letter Frequency Distribution'.
|
||||
DISPLAY '-----------------------------'.
|
||||
DISPLAY 'A : ' A-cnt OF Letter-disp ' '
|
||||
'N : ' N-cnt OF Letter-disp.
|
||||
DISPLAY 'B : ' B-cnt OF Letter-disp ' '
|
||||
'O : ' O-cnt OF Letter-disp.
|
||||
DISPLAY 'C : ' C-cnt OF Letter-disp ' '
|
||||
'P : ' P-cnt OF Letter-disp.
|
||||
DISPLAY 'D : ' D-cnt OF Letter-disp ' '
|
||||
'Q : ' Q-cnt OF Letter-disp.
|
||||
DISPLAY 'E : ' E-cnt OF Letter-disp ' '
|
||||
'R : ' R-cnt OF Letter-disp.
|
||||
DISPLAY 'F : ' F-cnt OF Letter-disp ' '
|
||||
'S : ' S-cnt OF Letter-disp.
|
||||
DISPLAY 'G : ' G-cnt OF Letter-disp ' '
|
||||
'T : ' T-cnt OF Letter-disp.
|
||||
DISPLAY 'H : ' H-cnt OF Letter-disp ' '
|
||||
'U : ' U-cnt OF Letter-disp.
|
||||
DISPLAY 'I : ' I-cnt OF Letter-disp ' '
|
||||
'V : ' V-cnt OF Letter-disp.
|
||||
DISPLAY 'J : ' J-cnt OF Letter-disp ' '
|
||||
'W : ' W-cnt OF Letter-disp.
|
||||
DISPLAY 'K : ' K-cnt OF Letter-disp ' '
|
||||
'X : ' X-cnt OF Letter-disp.
|
||||
DISPLAY 'L : ' L-cnt OF Letter-disp ' '
|
||||
'Y : ' Y-cnt OF Letter-disp.
|
||||
DISPLAY 'M : ' M-cnt OF Letter-disp ' '
|
||||
'Z : ' Z-cnt OF Letter-disp.
|
||||
STOP RUN.
|
||||
|
||||
|
||||
END-PROGRAM.
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
(defun tally-letter-frequency-in-file ()
|
||||
"Open a file and count the number of times each letter appears."
|
||||
(let ((alphabet "abcdefghijklmnopqrstuvwxyz") ; variable to hold letters we will be counting
|
||||
(current-letter) ; variable to hold current letter we will be counting
|
||||
(count) ; variable to count how many times current letter appears
|
||||
(case-fold-search t)) ; ignores case
|
||||
(find-file "~/Documents/Elisp/MobyDick.txt") ; open file in a buffer (or switch to buffer if file is already open)
|
||||
(while (>= (length alphabet) 1) ; as long as there is at least 1 letter left in alphabet
|
||||
(beginning-of-buffer) ; go to the beginning of the buffer
|
||||
(setq current-letter (substring alphabet 0 1)) ; set current-letter to first letter of alphabet
|
||||
(setq count (how-many current-letter)) ; count how many of this letter in file
|
||||
(end-of-buffer) ; go to the end of the buffer
|
||||
(insert (format "\n%s%s - %7d" current-letter (upcase current-letter) count)) ; write how many times that letter appears
|
||||
(setq alphabet (substring alphabet 1 nil))) ; remove first letter from alphabet
|
||||
(insert "\n")))
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
-- LetterFrequency.ex
|
||||
-- Count frequency of each letter in own source code.
|
||||
|
||||
include std/console.e
|
||||
include std/io.e
|
||||
include std/text.e
|
||||
|
||||
sequence letters = repeat(0,26)
|
||||
|
||||
sequence content = read_file("LetterFrequency.ex")
|
||||
|
||||
content = lower(content)
|
||||
|
||||
for i = 1 to length(content) do
|
||||
if content[i] > 96 and content[i] < 123 then
|
||||
letters[content[i]-96] += 1
|
||||
end if
|
||||
end for
|
||||
|
||||
for i = 1 to 26 do
|
||||
printf(1,"%s: %d\n",{i+96,letters[i]})
|
||||
end for
|
||||
|
||||
if getc(0) then end if
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
function frequency ($string) {
|
||||
$arr = $string.ToUpper().ToCharArray() |where{$_ -match '[A-KL-Z]'}
|
||||
$n = $arr.count
|
||||
$arr | group | foreach{
|
||||
[pscustomobject]@{letter = "$($_.name)"; frequency = "$([math]::round($($_.Count/$n),5))"; count = "$($_.count)"}
|
||||
} | sort letter
|
||||
}
|
||||
$file = "$($MyInvocation.MyCommand.Name )" #Put the name of your file here
|
||||
frequency $(get-content $file -Raw)
|
||||
|
|
@ -1,42 +1,41 @@
|
|||
/*REXX program counts the occurrences of all characters in a file, and note that all */
|
||||
/* Latin alphabet letters are uppercased for also counting {Latin} letters (both cases).*/
|
||||
/*════════════════════════════════════~~~~~~~~~~════════════════════════════════════════*/
|
||||
abc = 'abcdefghijklmnopqrstuvwxyz' /*define an (Latin or English) alphabet*/
|
||||
abcU= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /*define an uppercase version of [↑]. */
|
||||
parse arg fileID . /*this last char isn't a middle dot: · */
|
||||
if fileID=='' then fileID= 'JUNK.TXT' /*¿none specified? Then use the default*/
|
||||
totChars= 0; totLetters= 0 /*count of all chars and of all letters*/
|
||||
pad= left('',18); pad9= left('', 18%2) /*used for the indentations of output. */
|
||||
@.= 0 /*wouldn't it be neat to use Θ instead?*/
|
||||
do j=1 while lines(fileID)\==0 /*read the file 'til the cows come home*/
|
||||
rec= linein(fileID) /*get a line/record from the input file*/
|
||||
/* [↓] process all characters in REC.*/
|
||||
do k=1 for length(rec) /*examine/count each of the characters.*/
|
||||
totChars= totChars + 1 /*bump count of number of characters. */
|
||||
c= substr(rec, k, 1); @.c= @.c + 1 /*Peel off a character; bump its count.*/
|
||||
if \datatype(c, 'M') then iterate /*Not a Latin letter? Get next char.⌠*/
|
||||
totLetters= totLetters + 1 /*bump the count for [Latin] letters. ⌡*/
|
||||
upper c /* ◄─────◄ uppercase a Latin character.*/
|
||||
@..c= @..c + 1 /*bump the (Latin) letter's count. */
|
||||
end /*k*/ /*no Greek glyphs: αßΓπΣσµτΦΘΩδφε ··· */
|
||||
end /*j*/ /*maybe we're ½ done by now, or mäÿbé ¬*/
|
||||
LL= '(Latin) letter' /*literal used for a "SAY" (below). */
|
||||
w= length(totChars) /*used for right─aligning the counts. */
|
||||
say 'file ─────' fileId "───── has" j-1 'records and has' totLetters LL"s."; say
|
||||
do L=0 for 256; c= d2c(L) /*display all none─zero letter counts. */
|
||||
if @..c==0 then iterate /*Has a zero count? Then skip character*/
|
||||
say pad9 LL' ' c " (also" translate(c,abc,abcU)') count:' right(@..c, w)
|
||||
end /*L*/ /*we may be in a rut, but not a cañyon.*/
|
||||
say /*¡The old name for Eygpt was Æygpt! _*/
|
||||
say 'file ─────' fileId "───── has" totChars 'characters.' /* √ */
|
||||
say /*The name for « » chars is guillemets.*/
|
||||
do #=0 for 256; y= d2c(#) /*display all none─zero char counts. */
|
||||
if @.y==0 then iterate /*¿Å zero count? Then ignore character*/
|
||||
c= d2c(#); ch= c /*C is the character glyph of a char. */
|
||||
if c<<' ' | #==255 then ch= /*don't show some control characters. */
|
||||
if c==' ' then ch= 'blank' /*show a blank's {true} name. */
|
||||
say pad right(ch, 5) " ('"d2x(#,2)"'x character count:" right(@.c, w)
|
||||
end /*#*/ /*255 isn't quite ∞, but sometimes ∙∙∙ */
|
||||
say /*not a good place for dithering: ░▒▓█ */
|
||||
say pad pad9 '☼ end─of─list ☼' /*show we are at the end of the list. */
|
||||
/*§§§§ Talk about a mishmash of 2¢ comments. ▬▬^▬▬ stick a fork in it, we're all done. ☻*/
|
||||
-- 10 Nov 2025
|
||||
include Setting
|
||||
arg file
|
||||
if file='' then
|
||||
file='Miserables.txt'
|
||||
|
||||
say 'LETTER FREQUENCY'
|
||||
say version
|
||||
say
|
||||
call CountLetters(file)
|
||||
call ShowLetters
|
||||
call Timer
|
||||
exit
|
||||
|
||||
CountLetters:
|
||||
procedure expose Lett.
|
||||
arg file
|
||||
Lett.=0; a=0; b=0
|
||||
do while Lines(file)
|
||||
line=Linein(file); a+=1; l=Length(line); b+=l
|
||||
do i=1 to l
|
||||
d=C2d(Substr(line,i,1)); Lett.d+=1
|
||||
end
|
||||
end
|
||||
say a 'lines,' b 'characters'
|
||||
say
|
||||
return
|
||||
|
||||
ShowLetters:
|
||||
procedure expose Lett.
|
||||
say 'l hex dec count'
|
||||
say '----------------'
|
||||
do i=0 to 255
|
||||
if Lett.i>0 then do
|
||||
say D2c(i) Right(D2x(i),3) Right(i,3) Right(Lett.i,6)
|
||||
end
|
||||
end
|
||||
return
|
||||
|
||||
-- Timer
|
||||
include Timer
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
main (parms):+
|
||||
text =: <'In olden times when wishing still helped one,
|
||||
there lived a king whose daughters were all beautiful.
|
||||
But the youngest was so beautiful that the sun itself,
|
||||
which has seen so much, was astonished whenever it shone in her face.'
|
||||
text =: "In olden times when wishing still helped one, "
|
||||
text =_ "there lived a king whose daughters were all beautiful. "
|
||||
text =_ "But the youngest was so beautiful that the sun itself, "
|
||||
text =_ "which has seen so much, was astonished whenever it shone in her face."
|
||||
lc =: new map
|
||||
?# c =: string text give characters
|
||||
? string #ASCIIletters has character c
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ struct LetterFreq {
|
|||
}
|
||||
|
||||
fn main(){
|
||||
file := os.read_file('unixdict.txt')!
|
||||
file := os.read_file('unixdict.txt')?
|
||||
mut freq := map[rune]int{}
|
||||
for c in file {
|
||||
freq[c]++
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
filepath = "SPECIFY FILE PATH HERE"
|
||||
|
||||
Set objfso = CreateObject("Scripting.FileSystemObject")
|
||||
Set objdict = CreateObject("Scripting.Dictionary")
|
||||
Set objfile = objfso.OpenTextFile(filepath,1)
|
||||
|
||||
txt = objfile.ReadAll
|
||||
|
||||
For i = 1 To Len(txt)
|
||||
char = Mid(txt,i,1)
|
||||
If objdict.Exists(char) Then
|
||||
objdict.Item(char) = objdict.Item(char) + 1
|
||||
Else
|
||||
objdict.Add char,1
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each key In objdict.Keys
|
||||
WScript.StdOut.WriteLine key & " = " & objdict.Item(key)
|
||||
Next
|
||||
|
||||
objfile.Close
|
||||
Set objfso = Nothing
|
||||
Set objdict = Nothing
|
||||
Loading…
Add table
Add a link
Reference in a new issue