-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop_remover.e
45 lines (41 loc) · 1.02 KB
/
stop_remover.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
note
description: "Summary description for {STOP_REMOVER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
STOP_REMOVER
create
make
feature
make
do
end
remove_stops (list : LINKED_LIST[STRING]; stops : LINKED_LIST[STRING]) : LINKED_LIST[STRING]
local
crnt_word: STRING
checked_word: STRING
new_list: LINKED_LIST[STRING]
do
create new_list.make
new_list := list
across stops as word loop -- Itera por toda stop word
crnt_word := word.item.out
from
new_list.start
until
new_list.exhausted
loop -- Itera por toda a lista para cada stop word
checked_word := new_list.item.out
if checked_word.is_equal(crnt_word) then -- Se a palavra é igual à stop word atual, a remove
new_list.remove
else -- Se não, vai para o próximo elemento
new_list.forth
end
end
end
Result := new_list
ensure
remocao: Result.count <= list.count -- Garante que a nova lista é menor ou igual à original
end
end