Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -51,10 +51,11 @@ PROC count commands = ( STRING commands )INT:
|
|||
result
|
||||
END # count commands # ;
|
||||
|
||||
# build a table of the commands and their minimum lengths #
|
||||
# list of "commands" - the words are optionally followed by the minimum #
|
||||
# length of abbreviation - if there isn't a number #
|
||||
# the command can only appear in full #
|
||||
STRING commands
|
||||
STRING command list
|
||||
= "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 "
|
||||
+ "compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate "
|
||||
+ "3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 "
|
||||
|
|
@ -64,7 +65,6 @@ STRING commands
|
|||
+ "refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left "
|
||||
+ "2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1 "
|
||||
;
|
||||
# build the tables of the commands and their minimum lengths #
|
||||
PROC load commands = ( STRING commands )VOID:
|
||||
BEGIN
|
||||
INT cmd pos := 0;
|
||||
|
|
@ -82,6 +82,7 @@ PROC load commands = ( STRING commands )VOID:
|
|||
FI
|
||||
OD
|
||||
END # load commands # ;
|
||||
|
||||
# searches for word in command table and returns the full command #
|
||||
# matching the possible abbreviation or *error* if there is no match #
|
||||
OP EXPAND = ( STRING word )STRING:
|
||||
|
|
@ -122,9 +123,9 @@ PROC test expand = ( STRING words )VOID:
|
|||
END # test expand # ;
|
||||
|
||||
# build the command table #
|
||||
[ 1 : count commands( commands ) ]STRING command table;
|
||||
[ 1 : UPB command table ]INT min abbreviation;
|
||||
load commands( commands );
|
||||
[ 1 : count commands( command list ) ]STRING command table;
|
||||
[ 1 : UPB command table ]INT min abbreviation;
|
||||
load commands( commandlist );
|
||||
|
||||
# task test cases #
|
||||
test expand( "riG rePEAT copies put mo rest types fup. 6 poweRin" )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
Function Token(cad As String, tokens() As String) As Integer
|
||||
Dim As Integer n = 0
|
||||
Dim As String temp = ""
|
||||
Dim As Integer i
|
||||
|
||||
For i = 1 To Len(cad)
|
||||
If Mid(cad, i, 1) <> " " Then
|
||||
temp &= Mid(cad, i, 1)
|
||||
Elseif temp <> "" Then
|
||||
n += 1
|
||||
Redim Preserve tokens(1 To n)
|
||||
tokens(n) = temp
|
||||
temp = ""
|
||||
End If
|
||||
Next
|
||||
|
||||
If temp <> "" Then
|
||||
n += 1
|
||||
Redim Preserve tokens(1 To n)
|
||||
tokens(n) = temp
|
||||
End If
|
||||
|
||||
Return n
|
||||
End Function
|
||||
|
||||
Dim As String c = "add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3" & _
|
||||
" compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate" & _
|
||||
" 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2" & _
|
||||
" forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load" & _
|
||||
" locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2" & _
|
||||
" msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3" & _
|
||||
" refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left" & _
|
||||
" 2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1"
|
||||
c = Ucase(c)
|
||||
|
||||
Dim As String chunk()
|
||||
Dim As Integer i, j, n, v
|
||||
|
||||
n = Token(c, chunk())
|
||||
|
||||
Dim As Integer lonc(1 To n)
|
||||
|
||||
For i = 1 To n - 1
|
||||
v = Val(chunk(i + 1))
|
||||
If v Then
|
||||
lonc(i) = v
|
||||
chunk(i + 1) = ""
|
||||
Else
|
||||
lonc(i) = Len(chunk(i))
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim As String test = "riG rePEAT copies put mo rest types fup. 6 poweRin"
|
||||
test = Ucase(test)
|
||||
|
||||
Dim As String w()
|
||||
Dim As Integer x = Token(test, w())
|
||||
|
||||
Dim As Integer lonw(1 To x)
|
||||
|
||||
For i = 1 To x
|
||||
lonw(i) = Len(w(i))
|
||||
Next
|
||||
|
||||
Dim As String r = ""
|
||||
|
||||
For j = 1 To x
|
||||
Dim As String p = ""
|
||||
For i = 1 To n
|
||||
Dim As String lc = Left(chunk(i), lonw(j))
|
||||
Dim As String lw = w(j)
|
||||
If (lw = lc) And (lonc(i) <= lonw(j)) Then
|
||||
p = chunk(i)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
If p = "" Then p = "*error*"
|
||||
r &= " " & p
|
||||
Next
|
||||
|
||||
Print r
|
||||
|
||||
Sleep
|
||||
|
|
@ -26,17 +26,17 @@ end fn
|
|||
local fn Commands as CFArrayRef
|
||||
CFStringRef cmd, string
|
||||
long abbrLen
|
||||
CFMutableArrayRef commands = fn MutableArrayWithCapacity(0)
|
||||
CFMutableArrayRef commands = fn MutableArrayNew
|
||||
ScannerRef scanner
|
||||
|
||||
string = @" add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3"
|
||||
string = fn StringByAppendingString( string, @" compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate" )
|
||||
string = fn StringByAppendingString( string, @" 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2" )
|
||||
string = fn StringByAppendingString( string, @" forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load" )
|
||||
string = fn StringByAppendingString( string, @" locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2" )
|
||||
string = fn StringByAppendingString( string, @" msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3" )
|
||||
string = fn StringByAppendingString( string, @" refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left" )
|
||||
string = fn StringByAppendingString( string, @" 2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1" )
|
||||
string = concat( string, @" compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate" )
|
||||
string = concat( string, @" 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2" )
|
||||
string = concat( string, @" forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load" )
|
||||
string = concat( string, @" locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2" )
|
||||
string = concat( string, @" msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3" )
|
||||
string = concat( string, @" refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left" )
|
||||
string = concat( string, @" 2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1" )
|
||||
|
||||
scanner = fn ScannerWithString( string )
|
||||
while ( fn ScannerIsAtEnd( scanner ) == NO )
|
||||
|
|
@ -59,7 +59,7 @@ void local fn Validate
|
|||
commands = fn Commands
|
||||
userString = fn ControlStringValue( _userStringFld )
|
||||
words = fn StringComponentsSeparatedByCharactersInSet( userString, fn CharacterSetWhitespaceAndNewlineSet )
|
||||
results = fn MutableStringWithCapacity( 0 )
|
||||
results = fn MutableStringNew
|
||||
wordCount = len( words )
|
||||
|
||||
for i = 0 to wordCount - 1
|
||||
|
|
@ -83,7 +83,6 @@ void local fn Validate
|
|||
result = fn StringWithFormat( @"%@ ",ucase( cmd ) )
|
||||
break
|
||||
end if
|
||||
|
||||
next
|
||||
|
||||
MutableStringAppendString( results, result )
|
||||
|
|
@ -93,14 +92,12 @@ void local fn Validate
|
|||
ControlSetStringValue( _resultsStringFld, results )
|
||||
end fn
|
||||
|
||||
|
||||
void local fn DoDialog( ev as long, tag as long )
|
||||
select ( ev )
|
||||
case _btnClick : fn Validate
|
||||
end select
|
||||
end fn
|
||||
|
||||
|
||||
editmenu 1
|
||||
fn BuildWindow
|
||||
|
||||
|
|
|
|||
37
Task/Abbreviations-simple/NewLISP/abbreviations-simple.l
Normal file
37
Task/Abbreviations-simple/NewLISP/abbreviations-simple.l
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
(define (foo text)
|
||||
(let (command-table '() toks
|
||||
(map upper-case (parse (trim "
|
||||
add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1
|
||||
Schange Cinsert 2 Clast 3 compress 4 copy 2 count 3
|
||||
Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1
|
||||
duplicate 3 xEdit 1 expand 3 extract 3 find 1 Nfind 2
|
||||
Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 forward 2 get
|
||||
help 1 hexType 4 input 1 powerInput 3 join 1 split 2
|
||||
spltJOIN load locate 1 Clocate 2 lowerCase 3 upperCase
|
||||
3 Lprefix 2 macro merge 2 modify 3 move 2 msg next 1
|
||||
overlay 1 parse preserve 4 purge 3 put putD query 1
|
||||
quit read recover 3 refresh renum 3 repeat 3 replace 1
|
||||
Creplace 2 reset 3 restore 4 rgtLEFT right 2 left 2
|
||||
save set shift 2 si sort sos stack 3 status 4 top
|
||||
transfer 3 type 1 up 1"))))
|
||||
(local (tok amin word found? result)
|
||||
(until (empty? toks)
|
||||
(setq tok (pop toks))
|
||||
(setq amin
|
||||
(or (and (true? toks) (int (first toks)) (int (pop toks)))
|
||||
99))
|
||||
(push (list tok amin) command-table -1))
|
||||
(dolist (word (parse (trim text)))
|
||||
(setq word (upper-case word))
|
||||
(setq found? nil)
|
||||
(dolist (command-pair command-table found?)
|
||||
(when (or (= word (command-pair 0))
|
||||
(and (starts-with (command-pair 0) word)
|
||||
(>= (length word) (command-pair 1))))
|
||||
(setq found? (command-pair 0))))
|
||||
(push (or found? "*error*") result -1))
|
||||
(join result " "))))
|
||||
|
||||
(foo
|
||||
"riG rePEAT copies put mo rest types fup. 6 poweRin"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue