diff --git a/rascal/src/Makefile b/rascal/src/Makefile new file mode 100644 index 0000000..5f98518 --- /dev/null +++ b/rascal/src/Makefile @@ -0,0 +1,6 @@ +all: + +gen: + wget --no-check-certificate https://api.twitter.com/1/statuses/user_timeline/grammarware.json?count=3200 > grammarware.json + rsc TwiSKO.rsc + diff --git a/rascal/src/TwiSKO.rsc b/rascal/src/TwiSKO.rsc index 108461e..d190151 100644 --- a/rascal/src/TwiSKO.rsc +++ b/rascal/src/TwiSKO.rsc @@ -10,10 +10,17 @@ import IO; // println import String; //startsWith, endsWith import List; //size, reverse +public void main(list[str] as) +{ + go(); +} + public void go() { loc w = |home:///workspace/open/data/last1000.json|; loc r = |home:///workspace/open/data/last1000.xml|; + w = |cwd:///grammarware.json|; + r = |cwd:///grammarware.xml|; //loc w = |home:///workspace/open/data/one.json|; list[JSO] tweets = gimmeArray(loc2jso(w)); list[str] res = reverse([s | str s <- [processTweet(gimmeMap(tweet)) | JSO tweet <- tweets], s!=""]); @@ -29,7 +36,7 @@ str processTweet(map[str,JSO] t) return ""; return " '\ - ' \\" m=\"\" y=\"\"/\> + ' \\" m=\"\" y=\"\" time=\"\"/\> ' \\ ' \\ '\"; @@ -38,5 +45,6 @@ str processTweet(map[str,JSO] t) str t2day(map[str,JSO] t) = gimmeDay(gimmeString(t["created_at"])); str t2month(map[str,JSO] t) = gimmeMonth(gimmeString(t["created_at"])); str t2year(map[str,JSO] t) = gimmeYear(gimmeString(t["created_at"])); +str t2time(map[str,JSO] t) = gimmeTime(gimmeString(t["created_at"])); str t2id(map[str,JSO] t) = gimmeString(t["id_str"]); diff --git a/rascal/src/io/date/AccessTwitterDate.rsc b/rascal/src/io/date/AccessTwitterDate.rsc index 0da88f1..f654cb6 100644 --- a/rascal/src/io/date/AccessTwitterDate.rsc +++ b/rascal/src/io/date/AccessTwitterDate.rsc @@ -7,10 +7,12 @@ import String; public str gimmeDay(str x) = notrail(""); public str gimmeMonth(str x) = "")>"; public str gimmeYear(str x) = ""; +public str gimmeTime(str x) = ""; public str gimmeDay(loc x) = notrail(""); public str gimmeMonth(loc x) = "")>"; public str gimmeYear(loc x) = ""; +public str gimmeTime(loc x) = ""; str notrail(str s) { @@ -32,4 +34,4 @@ int monthno("Sep") = 19; int monthno("Oct") = 10; int monthno("Nov") = 11; int monthno("Dec") = 12; -default int monthno(str s) = "?"; +default int monthno(str s) = 0; diff --git a/rascal/src/io/date/SyntaxTwitter.rsc b/rascal/src/io/date/SyntaxTwitter.rsc index 7f88e2e..19f2b7d 100644 --- a/rascal/src/io/date/SyntaxTwitter.rsc +++ b/rascal/src/io/date/SyntaxTwitter.rsc @@ -2,7 +2,7 @@ module io::date::SyntaxTwitter start syntax TwiDate = TwiDateSimplified date; -lexical TwiDateSimplified = NotSpace [\ ] TwiMonth m [\ ] TwiDay d [\ ] NotSpace [\ ] NotSpace [\ ] TwiYear y; +lexical TwiDateSimplified = NotSpace [\ ] TwiMonth m [\ ] TwiDay d [\ ] NotSpace time [\ ] NotSpace adj [\ ] TwiYear y; lexical TwiMonth = [A-Z][a-z][a-z]; lexical TwiDay = [0-9][0-9]; lexical NotSpace = ![\ ]+ >> [\ ];