vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse twitter if exists; |
| 2 | create dataverse twitter; |
| 3 | use dataverse twitter; |
| 4 | create type Tweet as open { |
| 5 | id: int32, |
| 6 | tweetid: int64, |
| 7 | loc: point, |
| 8 | time: datetime, |
| 9 | text: string |
| 10 | } |
| 11 | |
| 12 | create external dataset TwitterData(Tweet) |
| 13 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 14 | (("path"="nc1://data/twitter/extrasmalltweets.txt"),("format"="adm")); |
| 15 | |
| 16 | write output to nc1:"rttest/groupby-orderby-count.adm"; |
| 17 | |
| 18 | for $t in dataset('TwitterData') |
| 19 | let $tokens := word-tokens($t.text) |
| 20 | for $token in $tokens |
| 21 | group by $tok := $token with $token |
| 22 | order by count($token) desc, $tok asc |
| 23 | return { "word": $tok, "count": count($token) } |