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