1

In the Amazon Mechanical Turk command line tools (I am using version: 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 that looks 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 about 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!

Asons
  • 84,923
  • 12
  • 110
  • 165
Vlad K.
  • 300
  • 3
  • 11

1 Answers1

2

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.

jrb
  • 578
  • 2
  • 10
  • - 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!!! – Vlad K. Jul 28 '10 at 22:29
  • PS: sorry but apparently no formatting works in copmments to comments:-). – Vlad K. Jul 28 '10 at 22:38
  • The suggestion to "use two arrays" was as a way to simulate tuples. Basically one array of keys (call it 'k' let's say) and another of values (call it 'v', say). You'd then get a tuple by calling k[1] and v[1]. Again, not a best-practice but if, for some reason, tuples aren't available it's a workaround to your Question #3. – jrb Mar 27 '16 at 21:38