70 likes | 167 Vues
Fetch, store, and analyze Twitter feeds using Ruby for data storage and Lexical Analyzer (Lex) for parsing. The program utilizes the Twitter API to fetch tweets, outputting data in JSON format, and uses Lex to tokenize and analyze text data. Future plans include integrating Bison & YACC for CFG string analysis in relation to the stock market.
E N D
Prototype I - Kimquy Craig Allen Long Nyguen Lyle Johnson Jason Alves-Foss
Leading Up To • Getting the Twitter feeds • Ruby • Storing • Data bank • Lexical analyzer • Lex
Ruby • Uses the Twitter api • Fetch numerous tweets by specific author • Google • Output to file • JSON format
require 'rubygems' require 'json' require 'net/http' uri= URI'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=bagder&&count=10' content =Net::HTTP.get(uri) json=JSON content myfile=File.open("tweets.txt", 'w+') json.each { |j| j.each { |key, value| myfile.write(value) if key =="text" } }
Flex • Opens file to parse data • Match strings • Tokenize • R.E. matching
%option yylineno %{ struct token *yytokens; /* a global array of all tokens */ intyyntokens; /* number of tokens in source file */ intyynallocated=0; /* size of dynamic array */ intnewlineflag; /* did a newline occur between last token and this? */ Inttabflag; %} %% [\t] { tabflag++; printf(“\t"); } [\n] { newlineflag++; printf(“\n”); } %% int main( intargc, char *argv[] ) { yyin = fopen( argv[1], "r" ); yylex(); return 0; fclose( yyin ); }
Upcoming • Bison & YACC • CFG • String Analyzing • Comparing/Matching • Stock Market • Relation