Re: Noobie needs help

2011-07-14 Thread Resty Cena
That works! Awesome!

On Thu, Jul 14, 2011 at 5:17 AM, Jonathan Fischer Friberg <
odysso...@gmail.com> wrote:

> I see I misunderstood the question, sorry about that.
>
> What you want is a macro:
>
> (defmacro string-maker [string-name the-string]
>   `(def ~(symbol string-name) ~the-string))
>
> Jonathan
>
>
> On Thu, Jul 14, 2011 at 1:13 PM, Giancarlo Angulo wrote:
>
>> Please look at this:
>> http://clojure.org/data_structures
>> see maps.
>> 
>>Giancarlo Angulo
>> 
>> -|-^_^X@^_^,=|+^_^X~_~@-
>> 
>>
>>
>>
>>
>> On Thu, Jul 14, 2011 at 2:41 PM, Tuba Lambanog 
>> wrote:
>>
>>> Hello,
>>> Total noobie here. I'm trying to create a sort of a string maker
>>> function. Something like:
>>>
>>> (defn string-maker [string-name the-string]
>>>  (def string-name (str the-string)))
>>>
>>> so that I can call the function like so:
>>>
>>> (string-maker "friend" "Peter")
>>>
>>> which I expect to give me the variable:   friend
>>> with the value: Peter
>>>
>>> But alas, no luck. Can anybody point me in the right direction?
>>> Thanks!
>>> tuba
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: (doc more-examples)

2011-07-16 Thread Resty Cena
Or an option for more extended doc when launching REPL for those who need
the extra documentation more than performance during development, or maybe a
searchable dictionary panel at the left hand side of REPL, ala some versions
of Ruby's irb.

Meanwhile, thanks for the pointer to the clojure quickref at clojuredocs.org.
Good enough.

Tuba

On Sat, Jul 16, 2011 at 9:11 PM, Stuart Halloway
wrote:

> On Sat, Jul 16, 2011 at 2:23 AM, Tuba Lambanog 
> wrote:
>
> More examples in how to use a form in the (doc ...) facility within
>
> REPL would be very useful to newbies. Thanks.
>
>
> That would mean the docstrings need to provide more detail in the
> source code. Not sure how practical that is since the docstrings would
> substantially outweigh the code - maybe Clojure/core could comment?
>
>
> I wouldn't use docstrings for this, as they increase runtime footprint.
>
> That said, an alternate doc macro could look other places besides
> docstrings. It shouldn't be difficult to write an examples macro that calls
> out to e.g. clojuredocs.org.
>
> Stu
>
>
> Stuart Halloway
> Clojure/core
> http://clojure.com
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: passing value to functions

2011-07-28 Thread Resty Cena
Hi, Thorsten,

Yes, you're right, once inside a function, the function is already being
applied. I mean that within the function, there's a test for whether the
input variable needs to be changed or not. Sort of vacuous application if
conditions are not met.

Yes, an enriched facility for pattern matching would be nice. I use a bit of
regular expression, a last resort for me.

<< Is there any reason to test additional rules after one matches, or would
it be beneficial to stop after a match? >>

Yes, the input may violate more than one spelling rule. So it is essential
that the output of a function feeds the next one.

Thanks for the help.

Tuba



On Thu, Jul 28, 2011 at 1:22 PM, Thorsten Wilms  wrote:

> On 07/28/2011 06:34 PM, Tuba Lambanog wrote:
>
>  The determination of whether a called function will apply is left as a
>> responsibility of the function itself, rather than the calling
>> function. The motivation is that a function may be called from a
>> number of places. Perhaps there's a better way?
>>
>
> The called function cannot decide to not be applied, but it may either
> evaluate to its argument (assuming unary), or a value derived from that
> argument.
>
> I guess pattern matching would be nice here, but even without, you could
> perhaps split the conditions from the actions. Is there any reason to test
> additional rules after one matches, or would it be beneficial to stop after
> a match? That would make it similar to URL routing like e.g. Moustache does
> it.
>
> From your description, it did sound like you want to call the 2nd function
> with the original argument, not the result of the 1st function. But how
> would you accumulate all the results, then?
>
>
> --
> Thorsten Wilms
>
> thorwil's design for free software:
> http://thorwil.wordpress.com/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscribe@**googlegroups.com
> For more options, visit this group at
> http://groups.google.com/**group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: passing value to functions

2011-07-28 Thread Resty Cena
Hi, Alan,

I can see that your suggestion will work. The key, as I understand it, is
the embedding of functions, thus:

 (fix-ize (fix-ou word)))

which is indeed a Lisp-y way of doing things. It seems imperatively I miss
elegant one-liners such as this.

I'm right now close to getting Laurent's approach to work.

Thanks much for your help.

Tuba

On Thu, Jul 28, 2011 at 1:56 PM, Alan Malloy  wrote:

> On Jul 28, 12:22 pm, Thorsten Wilms  wrote:
> > On 07/28/2011 06:34 PM, Tuba Lambanog wrote:
> >
> > > The determination of whether a called function will apply is left as a
> > > responsibility of the function itself, rather than the calling
> > > function. The motivation is that a function may be called from a
> > > number of places. Perhaps there's a better way?
> >
> > The called function cannot decide to not be applied, but it may either
> > evaluate to its argument (assuming unary), or a value derived from that
> > argument.
> >
> > I guess pattern matching would be nice here, but even without, you could
> > perhaps split the conditions from the actions. Is there any reason to
> > test additional rules after one matches, or would it be beneficial to
> > stop after a match? That would make it similar to URL routing like e.g.
> > Moustache does it.
> >
> >  From your description, it did sound like you want to call the 2nd
> > function with the original argument, not the result of the 1st function.
> > But how would you accumulate all the results, then?
>
> You don't need to "change" the original value at all - you just want
> to compute a new value, which, as Thorsten says, may be the same as
> the original, or not. Then pass that new value to another function
> that may decide to change it again, or not, and then...
>
>
> (defn fix-ou [word]
>  (clojure.string/replace word #"ou" "o"))
>
> (defn fix-ize [word]
>  (clojure.string/replace word #"ise" "ize"))
>
> (defn apply-all-fixes [word]
>  (fix-ize (fix-ou word)))
>
> (defn fix-whole-sentence [words]
>  (for [word words]
>(apply-all-fixes word)))
>
> user> (fix-whole-sentence ["don't" "criticise" "the" "labour"
> "party"])
> ("don't" "criticize" "the" "labor" "party")
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: passing value to functions

2011-07-28 Thread Resty Cena
Hi, Masanori,
Yes, I noticed the similarity. I'm using Laurent's 'manual way' for now.
I'll look at Alan's and Laurent's more concise solution in a few days. The
"manual way" is easy to debug as all I have to do is println the
intermediate results.
Thanks.
Tuba


2011/7/28 OGINO Masanori 

> Laurent's way and Alan's way have different surfaces, but same mean.
>
> (-> word fix-ou fix-ize)
> (fix-ize (fix-ou word))
>
> You can check it using clojure.walk/macroexpand-all.
>
> user=> (macroexpand-all '(-> "labour" fix-ou fix-ize))
> (fix-ize (fix-ou "labour"))
>
> Indeed you can choose only one way, I suggest considering two ways.
> Sometimes using -> is easy to read, and sometimes it is hard to do.
> (Readability is the matter in this case, right?)
>
> --
> Name:  OGINO Masanori (荻野 雅紀)
> E-mail: masanori.og...@gmail.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: "Elegant tools deserve elegant solutions." -- L. E. Gant

2011-08-08 Thread Resty Cena
Hi, Andreas,

<< I don't quite understand what you mean by "I’m having a hard time
thinking through the process of generating the
candidate suffix set using set forms" >>

It is my usual roundabout way of saying "I don't know how to do this." ;)

I'm looking at your code as we speak.

Thanks,
Tuba

On Mon, Aug 8, 2011 at 1:13 AM, Andreas Kostler <
andreas.koest...@leica-geosystems.com> wrote:

> Hi Tuba,
> I don't quite understand what you mean by "I’m having a hard time
> thinking through the process of generating the
> candidate suffix set using set forms" but I have created a porter
> stemmer for English in the past.
> I understand that's not what you're looking for but it is moreso a
> framwork for building stemmers:
>
> You specify rules of the like:
> {:c? condition :s1 "abc" :s2 "efg" :a action}
> reading if condition is met, replace s1 with s2 and execute action.
> Where s1 could be a suffix etc. All you need to do is specify these rules.
> Have a browse
> https://github.com/AndreasKostler/Stout
>
> Cheers
> Andreas
>
>
> On 8 August 2011 16:16, Tuba Lambanog  wrote:
> >
> > Hello,
> >
> > I’m doing a word stemmer for a non-English language. A stemmer parses
> > a word into its word parts: prefixes, roots, suffixes. The input word
> > is at least a root word (English example would be ‘cloud’), but can be
> > any combination of  prefix(es) and a root (e.g., 'pre-nuptial'), or a
> > root and suffix(es) (‘cloudy’), or all three ('unidirection'). A
> > sequence of more than one prefix in a word is considered one
> > occurrence of a prefix, and similarly for complex prefixes, thus,
> > ‘directional’ is considered to have the ‘single’ suffix ‘ional’. The
> > prefixes, roots, and suffixes are in their own set data structure.
> >
> > The approach I am pursuing is to create a set of potential suffixes
> > that the input word contains. Asssume, for simplicity, that the suffix
> > set consists of #{-or, -er, -al, -ion, -ional, able}. The input
> > ‘directional’ would have the candidate suffix set #{-al –ional}. Now,
> > drop the longest suffix (‘ional’) from the input then check the
> > remaining string (‘direct’) if it is a root; if it is, done. If not,
> > try the next suffix (‘-al’) in the potential suffix set.  Prefixes
> > will be similarly processed. Input words with both prefixes and
> > affixes will be fun to do ;)
> >
> > I’m having a hard time thinking through the process of generating the
> > candidate suffix set using set forms, and I’m beginning to think I
> > have selected an arduous path (for me).
> >
> > Thoughts?
> >
> > Thanks.
> > Tuba
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: "Elegant tools deserve elegant solutions." -- L. E. Gant

2011-08-08 Thread Resty Cena
Hi, Ken,

Thanks for the suggestion.

As I was looking at a suffix tree, it suddenly struck me that the following
strategy may do just as well:

1. Use rest and next to generate the tentative suffix sets, thus for
"directional", it will give the set of #{irectional rectional ectional
ctional  tional ional onal nal al l}.

2. Intersection this with the set of suffixes.

3. Select the longest item in the result set.

I'm trying this one out now.

Tuba


On Mon, Aug 8, 2011 at 11:23 AM, Ken Wesson  wrote:

> On Mon, Aug 8, 2011 at 11:41 AM, Tuba Lambanog 
> wrote:
> > Hi,
> > Thank you for the tip. It does look like the Patricia tree -- or suffix
> tree
> > -- is made-to-order for this kind of task. I'm reading up on it.
>
> You're welcome.
>
> > Would there be a Clojure implementation of this technology, I wonder.
>
> Even if not, it's probably trivial to slap one together, and test it,
> in less than a day in Clojure.
>
> As for generating your candidate seqs of prefixes and suffixes, just
> cons onto an initial nil in your reduction* and you'll end up with a
> seq that, traversed forwards, goes from longest candidate to shortest.
> For suffixes you'll want to (map #(apply str (reverse %)) the-seq),
> though, to get the suffixes the right way around (since they'll need
> to be stored reversed in their tree).
>
> --
> Protege: What is this seething mass of parentheses?!
> Master: Your father's Lisp REPL. This is the language of a true
> hacker. Not as clumsy or random as C++; a language for a more
> civilized age.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en