Exemplo n.º 1
0
 def __init__(self):
     self.parser = gen_parser()
     self.function_registry = FunctionRegistry()
     self.unnamed_operator_counter = 0
     self.twitter_td = twitter_tuple_descriptor()
Exemplo n.º 2
0
from tweeql.field_descriptor import ReturnType
from tweeql.function_registry import FunctionInformation, FunctionRegistry
from tweeql.query_runner import QueryRunner

class Url():
    return_type = ReturnType.STRING

    @staticmethod
    def factory():
        return Url().get_url

    def get_url(self, tuple_data, val):
        tuple_data['screen_name'] = tuple_data['author'].screen_name
        return 'http://twitter.com/%(screen_name)s/status/%(id)s' % tuple_data

fr = FunctionRegistry()
fr.register("url", FunctionInformation(Url.factory, Url.return_type))

class Entities():
    return_type = ReturnType.STRING

    @staticmethod
    def factory():
        return Entities().get_entities

    def get_entities(self, tuple_data, val):
        values = tuple_data['entities']
        value = values[val]
        if val == 'hashtags':
            return ','.join(list(set([v['text'].lower() for v in value])))
        elif val == 'user_mentions':
Exemplo n.º 3
0
def register_default_functions():
    fr = FunctionRegistry()
    fr.register("temperatureF", FunctionInformation(Temperature.factory, Temperature.return_type))
    fr.register("tweetLatLng", FunctionInformation(Location.factory, Location.return_type))
    fr.register("floor", FunctionInformation(Rounding.factory, Rounding.return_type))
    fr.register("strlen", FunctionInformation(StringLength.factory, StringLength.return_type))
    fr.register("meanDevs", FunctionInformation(MeanOutliers.factory, MeanOutliers.return_type))
    fr.register("sentiment", FunctionInformation(Sentiment.factory, Sentiment.return_type))
Exemplo n.º 4
0
from tweeql.exceptions import TweeQLException
from tweeql.field_descriptor import ReturnType
from tweeql.function_registry import FunctionInformation, FunctionRegistry
from tweeql.query_runner import QueryRunner


class StringLength():
    return_type = ReturnType.INTEGER

    @staticmethod
    def factory():
        return StringLength().strlen

    def strlen(self, tuple_data, val):
        """ 
            Returns the length of val, which is a string
        """
        return len(val)


fr = FunctionRegistry()
fr.register(
    "stringlength",
    FunctionInformation(StringLength.factory, StringLength.return_type))

runner = QueryRunner()
runner.run_query("SELECT stringlength(text) AS len FROM twitter_sample;",
                 False)
Exemplo n.º 5
0
def register_default_functions():
    fr = FunctionRegistry()
    fr.register("temperatureF", FunctionInformation(Temperature.factory, Temperature.return_type))
    fr.register("tweetLatLng", FunctionInformation(Location.factory, Location.return_type))
    fr.register("floor", FunctionInformation(Rounding.factory, Rounding.return_type))
    fr.register("strlen", FunctionInformation(StringLength.factory, StringLength.return_type))
    fr.register("meanDevs", FunctionInformation(MeanOutliers.factory, MeanOutliers.return_type))
    fr.register("sentiment", FunctionInformation(Sentiment.factory, Sentiment.return_type))
Exemplo n.º 6
0
from tweeql.exceptions import TweeQLException
from tweeql.field_descriptor import ReturnType
from tweeql.function_registry import FunctionInformation, FunctionRegistry
from tweeql.query_runner import QueryRunner

class StringLength():
    return_type = ReturnType.INTEGER

    @staticmethod
    def factory():
        return StringLength().strlen

    def strlen(self, tuple_data, val):
        """ 
            Returns the length of val, which is a string
        """
        return len(val)

fr = FunctionRegistry()
fr.register("stringlength", FunctionInformation(StringLength.factory, StringLength.return_type))

runner = QueryRunner()
runner.run_query("SELECT stringlength(text) AS len FROM twitter_sample;", False)