0

I know this is a very simple question but I seem to be having some problems.

I am trying to stem a list of words using porter_stem but I am getting an error:

Out of local stack

This is my code:

stemming([],[]).
stemming([H|T], A) :-
    stemming(T,Answer),
    porter_stem(H,S),
    append(Answer,S,A).

Basically the pseudocode for this is as follows:

for all items in list
    stem item
    add item to list2
    return list2

Can anyone please point me in the right direction please?

6
  • well, the first thing your stemming predicate does is to call stemming, it should be the last thing it does.
    – m09
    Jan 6, 2012 at 23:15
  • Thanks, fixed. Still gets the same error though :/
    – Lilz
    Jan 7, 2012 at 0:07
  • 2
    I can detail a normal recursion to you if you want, but did you try to use maplist/3 or equivalent depending on your prolog implementation ? something like maplist(porter_stem, List, Result). would suffice.
    – m09
    Jan 7, 2012 at 0:32
  • wow thanks. i didnt know maplist existed :O
    – Lilz
    Jan 7, 2012 at 0:46
  • 1
    @Mog: post that as an answer!
    – Fred Foo
    Jan 7, 2012 at 14:26

1 Answer 1

1

Consider using maplist/3 or equivalent depending on your prolog implementation: something like maplist(porter_stem, List, Result). would suffice.

If you're interested in learning how to build a proper recursion, post a comment and I'll try to expand my answer :)

1
  • Thank you so much! If I could understand what was wrong with the code I pasted, I would be everso grateful.
    – Lilz
    Jan 7, 2012 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.