Abbreviations, automatic: Difference between revisions
→{{header|REXX}}: ooRexx conformane, readability, duplicate wprd in list
imported>RegalCode (Added implementation for R) |
Walterpachl (talk | contribs) (→{{header|REXX}}: ooRexx conformane, readability, duplicate wprd in list) |
||
Line 6,698:
=={{header|REXX}}==
<syntaxhighlight lang="rexx"> /*REXX program finds the minimum length abbreviation for a lists of words (from a file).*/
Do While lines(iFID)\==0
/* [↓] process the file until done. */▼
If
Say ''
say right(minLen, 4) ' ' days /*display a somewhat formatted output. */▼
Else Do
If minlen='????' Then
End
@.= /*@. is a stemmed array of the words.*/▼
End
L=0 /*L is the max length of " " */▼
Exit
/*----------------------------------------------------------------------------------*/
abb: Procedure
Parse Arg daylist /* obtain list of words
dayn=words(daylist)
day.=''
L=0
Do j=1 for dayn
$=$ a /*so far, it's unique; add to the list.*/▼
day.j=word(daylist,j)
L.j=length(day.j)
leave m /*a good abbreviation length was found.*/▼
L= max(L,L.j)
End
return m</syntaxhighlight>▼
Do m=1 To L
abblist='' /* for all lengths,find a unique abbrev */
Do k=1 to dayn
abbrev=strip(left(day.k,m)) /* get an abbreviation (with length M). */
If wordpos(abbrev,abblist)>0 Then /* not unique */
If length(abbrev)>=m Then
End
End
m='????'
{{out|output|text= when using the default input file containing the complete list of words:}}
<pre style="height:45ex">
|