Inverted index: Difference between revisions

m
→‎{{header|REXX}}: added DO-END labels, removed a few superflous blanks. -- ~~~~
m (→‎{{header|REXX}}: added DO-END labels, removed a few superflous blanks. -- ~~~~)
Line 1,756:
=={{header|REXX}}==
Note: In this algorithm, word indices start at 1.
<lang rexx>/*REXX program illustrates building a simple inverted index & word find.*/
<lang rexx>
/*REXX program illustrates building a simple inverted index & word find.*/
 
@.='' /*dictionary of words (so far).*/
Line 1,778 ⟶ 1,777:
call findAword "burma-shave" /*and find yet another word. */
exit /*enough of this, I'm tired. */
 
 
 
/*─────────────────────────────────────FINDAWORD subroutine─────────────*/
findAword: procedure expose @. /*get A word, and uppercase it. */
Line 1,798 ⟶ 1,794:
parse var _ f w _
say ' file='f ' word='w
end /*until*/
 
return _@
 
 
/*─────────────────────────────────────INVERTI subroutine───────────────*/
invertI: procedure expose @. !; parse arg #,fn /*file#, filename*/
Line 1,823 ⟶ 1,817:
@.xxx=@.xxx # w
if wordpos(xxx,!)==0 then !=! xxx /*add to THE list of words found.*/
end /*until _=='' */
 
end /*while lines...*/
end
 
call lineout fn /*close the file, just to be neat*/
return w
 
 
/*─────────────────────────────────────STRIPPER subroutine──────────────*/
stripper: procedure; parse arg q /*remove punctuation at word-end.*/
Line 1,837 ⟶ 1,829:
do j=1 for length(@punctuation)
q=strip(q,'T',substr(@punctuation,j,1))
end /*j*/
 
return q</lang>
'''output'''
</lang>
Output:
<pre style="height:30ex;overflow:scroll">
file 0,record=Rip a fender