Hi!

Say I have the words

(def data ["bird" "cat" "whale" "elephant"])

and I want to calculate the ratio: words that has <= 4 letters / all
words. The sort of closest I get is:

(?<- (stdout) [?short ?count] (data ?word) (letters-4-or-more? ?word :>
?short) (c/count ?count))

(If that would actually work, there is some problem that I posted about in
another thread named "count breaks my queries".)

But is there a way to actually compute the ratio right there in the query?

Search Discussions

  • Oleksandr Petrov at Nov 28, 2012 at 8:46 am
    Just ran the query:

    (?<- (stdout) [?count] (data ?word) (cascalog.ops/count ?count))

    RESULTS
    -----------------------
    4
    -----------------------

    Works absolutely fine. Check your letters-4-or-more function, and setup
    generally.


    On Wed, Nov 28, 2012 at 9:00 AM, Oskar wrote:

    Hi!

    Say I have the words

    (def data ["bird" "cat" "whale" "elephant"])

    and I want to calculate the ratio: words that has <= 4 letters / all
    words. The sort of closest I get is:

    (?<- (stdout) [?short ?count] (data ?word) (letters-4-or-more? ?word :>
    ?short) (c/count ?count))

    (If that would actually work, there is some problem that I posted about in
    another thread named "count breaks my queries".)

    But is there a way to actually compute the ratio right there in the query?


    --
    alex p
  • Oskar at Nov 28, 2012 at 9:22 am
    I made another thread for my problem with the query not working, and in it
    there is no letters-4-or-more function, and there is also a stack trace.
    Maybe you just posted in the wrong one. Anyway, in this thread I was asking
    for a way to compute the ratio. Even my query had worked, it does not
    compute the ratio.
    On Wednesday, November 28, 2012 9:46:40 AM UTC+1, Alex P wrote:

    Just ran the query:

    (?<- (stdout) [?count] (data ?word) (cascalog.ops/count ?count))

    RESULTS
    -----------------------
    4
    -----------------------

    Works absolutely fine. Check your letters-4-or-more function, and setup
    generally.



    On Wed, Nov 28, 2012 at 9:00 AM, Oskar <oskar...@gmail.com <javascript:>>wrote:
    Hi!

    Say I have the words

    (def data ["bird" "cat" "whale" "elephant"])

    and I want to calculate the ratio: words that has <= 4 letters / all
    words. The sort of closest I get is:

    (?<- (stdout) [?short ?count] (data ?word) (letters-4-or-more? ?word :>
    ?short) (c/count ?count))

    (If that would actually work, there is some problem that I posted about
    in another thread named "count breaks my queries".)

    But is there a way to actually compute the ratio right there in the query?


    --
    alex p
  • Oleksandr Petrov at Nov 28, 2012 at 10:32 am
    Once again, bare count works. I have posted example with result.

    To calculate ratio, read up on custom operations.
    https://github.com/nathanmarz/cascalog/wiki/Guide-to-custom-operationsthere're
    several ways to do it. Aggregators section should help you.

    Calculate ratio is just a matter of division of 2 things, so is no brainer.
    What's important is how to count them.


    On Wed, Nov 28, 2012 at 10:22 AM, Oskar wrote:

    I made another thread for my problem with the query not working, and in it
    there is no letters-4-or-more function, and there is also a stack trace.
    Maybe you just posted in the wrong one. Anyway, in this thread I was asking
    for a way to compute the ratio. Even my query had worked, it does not
    compute the ratio.

    On Wednesday, November 28, 2012 9:46:40 AM UTC+1, Alex P wrote:

    Just ran the query:

    (?<- (stdout) [?count] (data ?word) (cascalog.ops/count ?count))

    RESULTS
    -----------------------
    4
    -----------------------

    Works absolutely fine. Check your letters-4-or-more function, and setup
    generally.


    On Wed, Nov 28, 2012 at 9:00 AM, Oskar wrote:

    Hi!

    Say I have the words

    (def data ["bird" "cat" "whale" "elephant"])

    and I want to calculate the ratio: words that has <= 4 letters / all
    words. The sort of closest I get is:

    (?<- (stdout) [?short ?count] (data ?word) (letters-4-or-more? ?word :>
    ?short) (c/count ?count))

    (If that would actually work, there is some problem that I posted about
    in another thread named "count breaks my queries".)

    But is there a way to actually compute the ratio right there in the
    query?


    --
    alex p

    --
    alex p
  • Andy Xue at Nov 28, 2012 at 5:24 pm
    yep alex is right, you need to figure out a condition count, ie, "count if"
    type of aggregate op
    On Wednesday, November 28, 2012 5:32:47 AM UTC-5, Alex P wrote:

    Once again, bare count works. I have posted example with result.

    To calculate ratio, read up on custom operations.
    https://github.com/nathanmarz/cascalog/wiki/Guide-to-custom-operationsthere're several ways to do it. Aggregators section should help you.

    Calculate ratio is just a matter of division of 2 things, so is no
    brainer.
    What's important is how to count them.



    On Wed, Nov 28, 2012 at 10:22 AM, Oskar <oskar...@gmail.com <javascript:>>wrote:
    I made another thread for my problem with the query not working, and in
    it there is no letters-4-or-more function, and there is also a stack trace.
    Maybe you just posted in the wrong one. Anyway, in this thread I was asking
    for a way to compute the ratio. Even my query had worked, it does not
    compute the ratio.

    On Wednesday, November 28, 2012 9:46:40 AM UTC+1, Alex P wrote:

    Just ran the query:

    (?<- (stdout) [?count] (data ?word) (cascalog.ops/count ?count))

    RESULTS
    -----------------------
    4
    -----------------------

    Works absolutely fine. Check your letters-4-or-more function, and setup
    generally.


    On Wed, Nov 28, 2012 at 9:00 AM, Oskar wrote:

    Hi!

    Say I have the words

    (def data ["bird" "cat" "whale" "elephant"])

    and I want to calculate the ratio: words that has <= 4 letters / all
    words. The sort of closest I get is:

    (?<- (stdout) [?short ?count] (data ?word) (letters-4-or-more? ?word :>
    ?short) (c/count ?count))

    (If that would actually work, there is some problem that I posted about
    in another thread named "count breaks my queries".)

    But is there a way to actually compute the ratio right there in the
    query?


    --
    alex p

    --
    alex p

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcascalog-user @
categoriesclojure, hadoop
postedNov 28, '12 at 8:05a
activeNov 28, '12 at 5:24p
posts5
users3
websiteclojure.org
irc#clojure

People

Translate

site design / logo © 2022 Grokbase