当前位置: 首页>>代码示例>>Python>>正文


Python Util.str_to_tuple方法代码示例

本文整理汇总了Python中lib.util.Util.str_to_tuple方法的典型用法代码示例。如果您正苦于以下问题:Python Util.str_to_tuple方法的具体用法?Python Util.str_to_tuple怎么用?Python Util.str_to_tuple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.util.Util的用法示例。


在下文中一共展示了Util.str_to_tuple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: infer

# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import str_to_tuple [as 别名]
    def infer(self, params):
        window = {'tweets':[], 'start':0} # storing tweets

        """ User distribution updating """
        for tweet in self.tweets.stream():
            if type(tweet) == type({}):
                self.update_user_distributions(tweet, params)

        """ Location prediction using user distribution """
        for user in self.users.iter():
            if user['location_point'] == None:
                """ unlabeled user """
                if user['id'] in self.user_distributions and len(self.user_distributions[user['id']]) > 0:
                    inferred_city = self.predict(self.user_distributions[user['id']], params)
                    inferred_location = Util.str_to_tuple(inferred_city)
                    user['location_point'] = inferred_location
开发者ID:yamaguchiyuto,项目名称:location_inference,代码行数:18,代码来源:cheng.py

示例2: infer_one

# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import str_to_tuple [as 别名]
    def infer_one(self, user_id):
        tweets = self.tweets.get(user_id)
        user_words = {}
        for tweet in tweets:
            for w in Util.get_nouns(tweet['text'], params['lang']):
                if not w in user_words: user_words[w] = 0
                user_words[w] += 1
        city_probs = {}
        for w in self.model['pwc']:
            for city in self.model['pwc'][w]:
                if not city in city_probs:
                    city_probs[city] = self.model['pc'][city]
                city_probs[city] *= self.model['pwc'][w][city]

        max_city = None
        max_prob = 0
        for city in city_probs:
            if max_prob < city_probs[city]:
                max_prob = city_probs[city]
                max_city = city
        return Util.str_to_tuple(max_city)
开发者ID:yamaguchiyuto,项目名称:location_inference,代码行数:23,代码来源:hecht.py


注:本文中的lib.util.Util.str_to_tuple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。