[erlang-questions] Printed list to Erlang function
Lloyd R. Prentice
lloyd@REDACTED
Wed Mar 30 04:05:03 CEST 2016
Wow! What a cool idea.
Thanks, Richard.
Best wishes,
LRP
Sent from my iPad
> On Mar 29, 2016, at 8:47 PM, "Richard A. O'Keefe" <ok@REDACTED> wrote:
>
>
>> On 30/03/16 5:59 am, lloyd@REDACTED wrote:
>> So, I have a printed list of stop words:
>>
>> http://www.ranks.nl/stopwords
>>
>> I'd like to turn this list into an Erlang function that I can query---
>>
>> stopwords() ->
>> ["word1", "word2" ... "wordN"].
>>
>> is_stopword(Word) ->
>> List = stopwords(),
>> lists_member(Word, List).
> Even if there is some arcane reason why you want the collection of words
> as a list, I strongly suggest generating
>
> is_stopword("a") -> true;
> is_stopword("about") -> true;
> ...
> is_stopword("yourselves") -> true;
> is_stopword(_) -> false.
>
> Open the list of stopwords in vi.
> :1,$s/^.*$/is_stopword("&") -> true;/
> :$a
> is_stopword(_) -> false.
> <ESC>
>
> The Erlang compiler will turn this into a trie, roughly speaking.
> This will be *dizzyingly* faster than the code you outlined.
>
>
>
>
>>
>> All my efforts so far have evolved into ugly kludges. Seems to me there must be an elegant method that I'm overlooking.
>>
>> Some kind soul point the way?
>>
>> Many thanks,
>>
>> LRP
>>
>> *********************************************
>> My books:
>>
>> THE GOSPEL OF ASHES
>> http://thegospelofashes.com
>>
>> Strength is not enough. Do they have the courage
>> and the cunning? Can they survive long enough to
>> save the lives of millions?
>>
>> FREEIN' PANCHO
>> http://freeinpancho.com
>>
>> A community of misfits help a troubled boy find his way
>>
>> AYA TAKEO
>> http://ayatakeo.com
>>
>> Star-crossed love, war and power in an alternative
>> universe
>>
>> Available through Amazon or by request from your
>> favorite bookstore
>>
>>
>> **********************************************
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list