Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading Aspell Dictionary in native language
#1
Referring to QM topic Spelling checker : I came up with reading the dictionary in my native language, using the following functions :

Function tempf12
Code:
Copy      Help
str sf="C:\Documents and Settings\S.E.Simopoulos\My QM\Aspell\dict\el.rws"
str sout s
int l new

rep 1500 ;; in this example I read only a small part of it
,sout.getfile(sf new)
,l=len(sout)
,if l=0
,,new=new+1
,else
,,sout.ToUnicode
,,out F"{l} {sout}"
,,new=new+l+1


Member function str.ToUnicode
Code:
Copy      Help
function [str'sinp]

if empty(sinp)
,str s=this
else
,s=sinp
,
s.unicode(s CP_ACP)
s.ansi(s)
this=s
ret

Any advice for a more efficient - elegant solution to either this implementation or that in the above topic will be much appreciated.
#2
New, improved approach :

Function tempf14
Code:
Copy      Help
str sf="C:\Documents and Settings\S.E.Simopoulos\My QM\Aspell\dict\el.rws"
str sout s sl
out
s.getfile(sf)
int i l n is ie
l=s.len

for i 0 1500
,if s[i]<>0; continue
,ie=i
,if is=ie
,,is=ie+1
,,continue
,sl.get(s is ie)
,sl.ToUnicode
;,out F"{is} {ie} {sl}"
,is=ie+1
,sout.formata("%s[]" sl)

out sout

,
#3
I would replace ToUnicode with ConvertEncoding(CP_ACP -1), and do it before for. Also formata -> addline.
#4
Many thanks !
#5
I am afraid that if you put ConvertEncoding(CP_ACP -1) before for (s.ConvertEncoding(CP_ACP -1)) it does not work. However, if you replace sl.ToUnicode with sl.ConvertEncoding(CP_ACP -1) it is OK. Am I missing something?
#6
Your code is correct. Probably depends on file format. Or does not work if you put it after l=s.len.


Forum Jump:


Users browsing this thread: 1 Guest(s)