Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,55 @@
V command_table_text =
|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
V user_words = riG rePEAT copies put mo rest types fup. 6 poweRin
F find_abbreviations_length(command_table_text)
find the minimal abbreviation length for each word.
a word that does not have minimum abbreviation length specified
gets it's full lengths as the minimum.
[String = Int] command_table
V input_list = command_table_text.split(( , "\n"), group_delimiters' 1B)
V i = 0
V word =
L i < input_list.len | word !=
I word ==
word = input_list[i++]
V abbr_len = I i < input_list.len {input_list[i++]} E String(word.len)
X.try
command_table[word] = Int(abbr_len)
word =
X.catch ValueError
command_table[word] = word.len
word = abbr_len
R command_table
F find_abbreviations(command_table)
for each command insert all possible abbreviations
[String = String] abbreviations
L(command, min_abbr_len) command_table
L(l) min_abbr_len .. command.len
V abbr = command[0 .< l].lowercase()
abbreviations[abbr] = command.uppercase()
R abbreviations
F parse_user_string(user_string, abbreviations)
V user_words = user_string.split( , group_delimiters' 1B).map(word -> word.lowercase())
V commands = user_words.map(user_word -> @abbreviations.get(user_word, *error*))
R commands.join( )
V command_table = find_abbreviations_length(command_table_text)
V abbreviations_table = find_abbreviations(command_table)
V full_words = parse_user_string(user_words, abbreviations_table)
print(user words: user_words)
print(full words: full_words)