If subject starts from 'Tweet from...'
    then we need to get first meaning line from the body.
352866
def swap_twitter_subject(subject, body):
    """"""

    if subject.startswith('Tweet from'):
        lines = body.split('\n')
        for idx, line in enumerate(lines):
            if re.match(r'.*, ?\d{2}:\d{2}]]', line) is not None:
                try:
                    subject = lines[idx + 1]
                except IndexError:
                    pass
                break
    return subject, body
918740
function(tweet, streamChannels){
    helpers.postprocessTweet(tweet, streamChannels);
    return helpers.emitPosprocessedTweet(tweet, streamChannels);
  }
136295
def getTamilWords( tweet ):
        "
        tweet = TamilTweetParser.cleanupPunct( tweet );
        nonETwords = filter( lambda x: len(x) > 0 , re.split(r'\s+',tweet) );#|"+|\'+|#+
        tamilWords = filter( TamilTweetParser.isTamilPredicate, nonETwords );
        return tamilWords
285817
def from_text(self, line, line_index, column, is_escaped):
        """"""
        begin = self._begin
        end = self._end
        single = self._single

        single_len = len(single)
        start_len = len(begin)

        if _token_at_col_in_line(line, column, single, single_len):
            return (STATE_IN_COMMENT,
                    (line_index, column + single_len),
                    ParserState.EOL)
        elif _token_at_col_in_line(line, column, begin, start_len):
            return (STATE_IN_COMMENT,
                    (line_index, column + single_len),
                    end)
        elif ((_token_at_col_in_line(line, column, "\"") or
               _token_at_col_in_line(line, column, "'")) and
              not _is_escaped(line, column, is_escaped)):
            # Check here to see whether this is a quote or if this
            # is a spellcheckable line
            if (_token_at_col_in_line(line, column, "\"\"\"") or
                    _token_at_col_in_line(line, column, "'''")):
                return (STATE_IN_COMMENT,
                        (line_index, column + 3),
                        line[column:column + 3])
            else:
                return (STATE_IN_QUOTE,
                        (line_index, column + 1),
                        line[column:column + 1])

        return (STATE_IN_TEXT,
                (0, 0),
                None)
1276330
def from_line(cls, line):
        """"""
        line = line.decode(defenc)
        fields = line.split('\t', 1)
        if len(fields) == 1:
            info, msg = fields[0], None
        elif len(fields) == 2:
            info, msg = fields
        else:
            raise ValueError("Line must have up to two TAB-separated fields."
                             " Got %s" % repr(line))
        # END handle first split

        oldhexsha = info[:40]
        newhexsha = info[41:81]
        for hexsha in (oldhexsha, newhexsha):
            if not cls._re_hexsha_only.match(hexsha):
                raise ValueError("Invalid hexsha: %r" % (hexsha,))
            # END if hexsha re doesn't match
        # END for each hexsha

        email_end = info.find('>', 82)
        if email_end == -1:
            raise ValueError("Missing token: >")
        # END handle missing end brace

        actor = Actor._from_string(info[82:email_end + 1])
        time, tz_offset = parse_date(info[email_end + 2:])

        return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), msg))
1239258
def substitute_infinitives_as_subjects(sent_str):
    """"""
    sent_doc = textacy.Doc(sent_str, lang='en_core_web_lg')
    #inf_pattern = r'<PART><VERB>+' # To aux/auxpass* csubj
    inf_pattern = r'<PART><VERB>' # To aux/auxpass* csubj
    infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern)
    inf_subjs = [] # => [[0,1],...]
    for inf in infinitives:
        if inf[0].text.lower() != 'to':
            continue
        if ('csubj' not in [w.dep_ for w in inf] and sent_doc[inf[-1].i + 1].dep_
                != 'csubj'):
            continue
        if inf[-1].tag_ != 'VB':
            continue
        inf_subj = []
        for v in inf:
            inf_subj.append(v.i)
        inf_subjs.append(inf_subj) 
    new_sent_str = sent_str
    unusual_char = '形'
    for inf_subj in inf_subjs:
        start_inf = sent_doc[inf_subj[0]].idx 
        end_inf = sent_doc[inf_subj[-1]].idx + len(sent_doc[inf_subj[-1]])
        inf_len = end_inf - start_inf
        sub = (unusual_char * inf_len)
        new_sent_str = new_sent_str[:start_inf] + sub + new_sent_str[end_inf:]
    new_sent_str = re.sub('形+', '{}', new_sent_str)
    repl = [conjugate(sent_doc[i_s[-1]].text, tense='presentparticiple') for i_s in inf_subjs]
    return new_sent_str.format(*repl)
416774
public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            List<Status> statuses = twitter.getFavorites();
            for (Status status : statuses) {
                System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
            }
            System.out.println("done.");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get favorites: " + te.getMessage());
            System.exit(-1);
        }
    }
1197041
def makeRetweetNetwork(tweets):
    
    G=x.DiGraph()
    G_=x.DiGraph()
    for tweet in tweets:
        text=tweet["text"]
        us=tweet["user"]["screen_name"]
        if text.startswith("RT @"):
            prev_us=text.split(":")[0].split("@")[1]
            #print(us,prev_us,text)
            if G.has_edge(prev_us,us):
                G[prev_us][us]["weight"]+=1
                G_[prev_us][us]["weight"]+=1
            else:
                G.add_edge(prev_us, us, weight=1.)
                G_.add_edge(prev_us, us, weight=1.)
        if us not in G_.nodes():
            G_.add_node(us)
    return G,G_
229088
def urlize_tweet(tweet):
    
    text = tweet.get('html', tweet['text'])
    for hash in tweet['entities']['hashtags']:
        text = text.replace('#%s' % hash['text'], TWITTER_HASHTAG_URL % (quote(hash['text'].encode("utf-8")), hash['text']))
    for mention in tweet['entities']['user_mentions']:
        text = text.replace('@%s' % mention['screen_name'], TWITTER_USERNAME_URL % (quote(mention['screen_name']), mention['screen_name']))
    tweet['html'] = text
    return tweet
672030
def msg_intro(self):
        """"""
        delim = self.style.attr_minor(self.style.delimiter)
        txt = self.intro_msg_fmt.format(delim=delim).rstrip()
        return self.term.center(txt)
421321
def start
      keywords = self.params["keywords"]
      @thread = Thread.new do 
        @client.filter_by_keywords(keywords) do |status|
          if retweet?(status)
            before_retweet.trigger(status)
            @retweet.retweet(status["id"])
            after_retweet.trigger(status)
          end
        end
      end
      @thread.join
    end
68667
def dweet_for(thing_name, payload, key=None, session=None):
    
    if key is not None:
        params = {'key': key}
    else:
        params = None
    return _send_dweet(payload, '/dweet/for/{0}'.format(thing_name), params=params, session=session)
8762
private static Tweets addTweets(User user, String body, Date tweetDate, String tweetId)
    {
        Tweets tweet = new Tweets();
        tweet.setTweetId(tweetId);
        tweet.setBody(body);
        tweet.setTweetDate(tweetDate);
        user.getTweets().add(tweet);
        return tweet;
    }
1178784
def next_intent_handler(request):
    

    message = "Sorry, couldn't find anything in your next queue"
    end_session = True
    if True:
        user_queue = twitter_cache.user_queue(request.access_token())
        if not user_queue.is_finished():
            message = user_queue.read_out_next(MAX_RESPONSE_TWEETS)
            if not user_queue.is_finished():
                end_session = False
                message = message + ". Please, say 'next' if you want me to read out more. "
    return alexa.create_response(message=message,
                                 end_session=end_session)
355061
def nextComment(self, text, start=0):
        

        m = min([self.lineComment(text, start),
                 self.blockComment(text, start),
                 self._emptylineregex.search(text, start)],
                key=lambda m: m.start(0) if m else len(text))
        return m
191007
def reply(tweet_text, options = {})
      return if $bot.nil? or $bot[:client].nil?
      opts = {
        reply_all: false
      }.merge(options)

      mentions = self.mentioned_users(opts[:reply_all])

      result = "@#{mentions.join(" @")} #{tweet_text}"[(0...140)]

      $bot[:client].update result, in_reply_to_status_id: self.id
    rescue Twitter::Error => e
      puts "caught Twitter error while replying: #{e.message}"
    end
707671
def parse_one(tweet)
      puts "==> #{tweet['id']}" if @options.verbose
      retdict = {
        mentions: {},
        hashtags: {},
        time_of_day: 0,
        retweet: false,
        client: {
          name: "",
          url: "",
        },
        smileys: {}
      }

      # check if the tweet is actually a retweet and ignore the status text
      unless tweet['retweeted_status'].nil?
        retdict[:retweet] = true
      else
        # scan for mentions
        tweet['text'].scan USERNAME_REGEX do |user|
          hash_user = user[0].downcase
          puts "===> mentioned: #{user[0]}" if @options.verbose
          unless @config[:ignored_users].include? hash_user
            if @config[:renamed_users].include? hash_user.to_sym
              hash_user = @config[:renamed_users][hash_user.to_sym]
            end
            retdict[:mentions][hash_user] ||= {}
            retdict[:mentions][hash_user][:name] ||= user[0]
            retdict[:mentions][hash_user][:count] = retdict[:mentions][hash_user][:count].to_i.succ
            retdict[:mentions][hash_user][:example] ||= { text: tweet['text'], id: tweet['id'] }
          end
        end

        # scan for hashtags
        tweet['text'].scan HASHTAG_REGEX do |hashtag|
          hash_hashtag = hashtag[0].downcase
          puts "===> hashtag: ##{hashtag[0]}" if @options.verbose
          retdict[:hashtags][hash_hashtag] ||= {}
          retdict[:hashtags][hash_hashtag][:hashtag] ||= hashtag[0]
          retdict[:hashtags][hash_hashtag][:count] = retdict[:hashtags][hash_hashtag][:count].to_i.succ
          retdict[:hashtags][hash_hashtag][:example] ||= { text: tweet['text'], id: tweet['id'] }
        end

        # Smileys :^)
        eyes = "[xX8;:=%]"
        nose = "[-oc*^]"
        smile_regex = /(>?#{eyes}'?#{nose}[\)pPD\}\]>]|[\(\{\[<]#{nose}'?#{eyes}<?|[;:][\)pPD\}\]\>]|\([;:]|\^[_o-]*\^[';]|\\[o.]\/)/
        frown_regex = /(#{eyes}'?#{nose}[\(\[\\\/\{|]|[\)\]\\\/\}|]#{nose}'?#{eyes}|[;:][\(\/]|[\)D]:|;_+;|T_+T|-[._]+-)/

        unescaped_tweet = tweet['text'].gsub("&amp;", "&").gsub("&lt;", "<").gsub("&gt;", ">")

        unescaped_tweet.scan smile_regex do |smile|
          smile = smile[0]
          puts "===> smile: #{smile}" if @options.verbose
          retdict[:smileys][smile] ||= {frown: false}
          retdict[:smileys][smile][:smiley] ||= smile
          retdict[:smileys][smile][:count] = retdict[:smileys][smile][:count].to_i.succ
          retdict[:smileys][smile][:example] ||= { text: tweet['text'], id: tweet['id'] }
        end

        unescaped_tweet.scan frown_regex do |frown|
          break unless unescaped_tweet !~ /\w+:\/\// # http:// :^)
          frown = frown[0]
          puts "===> frown: #{frown}" if @options.verbose
          retdict[:smileys][frown] ||= {frown: true}
          retdict[:smileys][frown][:smiley] ||= frown
          retdict[:smileys][frown][:count] = retdict[:smileys][frown][:count].to_i.succ
          retdict[:smileys][frown][:example] ||= { text: tweet['text'], id: tweet['id'] }
        end
      end

      # Tweet source (aka. the client the (re)tweet was made with)
      source_matches = tweet['source'].match SOURCE_REGEX
      retdict[:client][:url]  = source_matches[1]
      retdict[:client][:name] = source_matches[2]

      # Time of day
      retdict[:time_of_day] = (tweet['created_at'].match(/^\d{4}-\d{2}-\d{2} (\d{2})/)[1].to_i + @config[:timezone_difference]) % 24

      retdict
    end