Learning Lisp Syntax
Posted: Wed Oct 06, 2010 2:39 pm
I'm running the SLIME + EMACS Lispbox with CLISP. The SLIME menu has a link to LISP Hyperspec but I can't find how to convert the value of a symbol to a string. I'm thinking about using coerce, defvar or defparameter or something else like a fill-pointer but the Hyperspec examples given don't help much. What is the best way to work out how to do what I want? I am trying to refactor and extend a very old program in which a word from a sentence (without enclosing quotes) is assigned to a global variable called *curr-w* (for 'current word being processed'). I want to detect a specific suffix such as "ly" and create a lemmatized stem of *curr-w* if the original word is not in my lexicon. I know about the porter and snowball algorithms and CL-PPCRE but for now I just want to figure something out on my own. I have source code for a porter stemmer to possibly emulate it and eventually incorporate it later but it uses double quoted words.E.g. (stem "slowly")
If I try where *curr-w* is the word 'slowly' without the quotes, the value returned is "slowly" which seems like what I want since returns "wols" which is what I want. However, when I reverse morph and use (string-left-trim "yl" morph), the value returned is "ylwols" (unchanged) or an error message appears that says *curr-w* or morph is not a sequence. I have reversed the word to use string= and string-left-trim because I don't know what the length of the words will be and I'm not sure how to use string= running from the right side. I've tried adding quote before morph and (string morph) etc. Eventually, I want something like (string-left-trim suffix morph) that returns the stem of the word so that it can be checked for in the lexicon or ignored as an unknown word.
If I try
Code: Select all
(setf morph (string *curr-w*))
Code: Select all
(string-left-trim "yl" "ylwols")