1 / 7

Twitter Feed Analyzer: Ruby & Lexical Analysis

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.

lloyd
Télécharger la présentation

Twitter Feed Analyzer: Ruby & Lexical Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prototype I - Kimquy Craig Allen Long Nyguen Lyle Johnson Jason Alves-Foss

  2. Leading Up To • Getting the Twitter feeds • Ruby • Storing • Data bank • Lexical analyzer • Lex

  3. Ruby • Uses the Twitter api • Fetch numerous tweets by specific author • Google • Output to file • JSON format

  4. 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" } }

  5. Flex • Opens file to parse data • Match strings • Tokenize • R.E. matching

  6. %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 ); }

  7. Upcoming • Bison & YACC • CFG • String Analyzing • Comparing/Matching • Stock Market • Relation

More Related