views:

49

answers:

1

Hi, in Amazon Mechanical Turk command line tools (I have aws-mturk-clt-1.3.0), in one of the samples (site_filter_qual: "Website Filtering Qualification", file site_filter_qual.question), there is code looking something like this:

#set( $urls = [ "http://news.bbc.co.uk/", http://..., ...])

#foreach ( $url in $urls )
...

I am wondering :

  • a) what is the language used here(it's not Perl and not PHP, right?);
  • b) where (on Amazon site or elsewhere) I could read ab. these constructs;
  • c) how to implement tuples (pairs), e.g.

// in Python:

>> data = [("http://news.bbc.com", "NEWS"), ("http://google.com", "SEARCH"), ...]
>> for (url, category) in data:
>>     ....

-- or something similar?

Thanks in advance!

+1  A: 

It's a Velocity template (part of the Apache project). The good news is that it's a reasonably flexible language that you can manipulate. The better news is that you can (since I believe all the CLT and SDK code is open) actually create new constructs to override or expand on anything that's not part of Velocity out-of-the-box.

To answer your questions directly:

a) Velocity

b) http://velocity.apache.org/

c) You can use two separate arrays. Not pretty, I realize, but it'll work.

- 1) THANKS!!! - 2) "use two arrays": I still dont get it, could you please give a short example? I mean, -- I probably need smth. like #set( $urls = [...]) #set( $cats = [...])-- but foreach still won't work? I need smth. like > for (int i = 0; i < len($urls); i++)> do_smth_with $urls[i] .... -- but are these constructs there? what is the syntax?I didn't find any loops except "foreach" at http://velocity.apache.org/engine/devel/user-guide.html (:_.// Although this very page *mentions* "Hashtable" -- w/o bothering to describe the syntax! Sick!!!
mabooka
PS: sorry but apparently no formatting works in copmments to comments:-).
mabooka

related questions