コード例 #1
0
 def __init__(self):
     self.parser = gen_parser()
     self.function_registry = FunctionRegistry()
     self.unnamed_operator_counter = 0
     self.twitter_td = twitter_tuple_descriptor()
コード例 #2
0
ファイル: functions.py プロジェクト: gawel/tweeql2solr
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':
コード例 #3
0
ファイル: builtin_functions.py プロジェクト: TLOshini/tweeql
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))
コード例 #4
0
ファイル: tweeql-udf.py プロジェクト: tcpavel/tweeql
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)
コード例 #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))
コード例 #6
0
ファイル: tweeql-udf.py プロジェクト: GordonMac007/tweeql
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)