bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] Spell corrector - APL


From: Ala'a Mohammad
Subject: [Bug-apl] Spell corrector - APL
Date: Sat, 10 Sep 2016 01:39:45 +0400

Hi,

I'm trying to create simple spell corrector (Norvig at
http://norvig.com/spell-correct.html) in APL.
I tried but stumbled upon the frequency/count stage and could not move
further. The stopper was either WS Full, or apl process killed. I'm
assuming the main issue is 'lack of experience with APL', and thus the
inefficient coding.

ftxt ← { ⎕FIO[26] ⍵ }
a ← 'abcdefghijklmnopqrstuvwxyz'
A ← 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
downcase ← { (a,⎕AV)[(A,⎕AV)⍳⍵] }
nl ← ⎕UCS 13
cr ← ⎕UCS 10
tab ← ⎕UCS 9
nonalpha ← nl, cr, tab, ' 0123456789()[]!?%$,.:;/+*=<>-_#"`~@&'
alphamask ← { ~ ⍵ ∊ nonalpha }
hist ← { (⍪∪⍵),+/∨/¨(∪⍵)∘.⍷⍵ }
fhist ← { hist (alphamask txt) ⊂ downcase txt ← ftxt ⍵ }
⍝ file ← '/misc/small.txt' ~ 28K
⍝ file ← '/misc/xaa' ~ 1.3M
file ← '/misc/big.txt' ⍝ ~ 6.2M
⍝ following 2 lines for debugging
⎕ ← ⍴w ← (alphamask txt) ⊂ downcase txt ← ftxt file
⎕ ← ⍴u ← ∪w
fhist file

the errors happened inside 'hist' function, and I presume mostly due
to the jot dot find (if understand correctly, operating on a matrix of
length equal to : unique-length * words-length)

Is there anyway to fix the issue? and then proceed to complete the solution.

Also, Is this the way to create simple spell corrector in APL (that is
a one which is capitalizing on APL strength as an array language)?

I'm using
LinuxMint 17.1 (kernel 3.13.0-37-generic #64-Ubuntu)
Gnu APL 1.6 (794)
Zsch 5.0.2
Emacs 25.1.50.1

Best,

Ala'a

P.S: I hoped that I could create the solution in APL and then get some
wacks on the head from fellow experienced APL programmers before
submitting it as 'another solution in X language'. but the hope
stopped short before even getting the probability stage.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]