本文整理汇总了Python中analyzer.Analyzer.process_data方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.process_data方法的具体用法?Python Analyzer.process_data怎么用?Python Analyzer.process_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.process_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import process_data [as 别名]
class Manager:
"""
Actual object to manage everything
"""
# reference to the entire data storage
__cache = None
# reference to object managing articles access and storage
__articles = None
# reference to the object doing the analysis
__analyzer = None
def __init__(self, config):
"""
Prepare the entire system's objects
config - the configuration object from the click library
"""
yaml_config = yaml.load(config.obj["config"])
config.obj["config"].close()
self.__cache = Cache(db_file=config.obj["database"])
self.__articles = Articles(key=yaml_config["api_key"], cache=self.__cache)
self.__analyzer = Analyzer()
def perform_search(self, phrase, training_size=1000):
"""
Perform the actual search either to cache or ny times
phrase - the phrase to search by
training_size - the amount of articles to use and fetch
returns the list of found articles
"""
return self.__articles.perform_search(phrase, training_size)
def analyze_results(self, article_list):
"""
Perform the regression analysis on the results and print
them out to the command line
"""
print("Using %i articles" % (len(article_list),))
self.__analyzer.process_data(article_list)
def predict_result(self, date):
"""
Make a prediction on a date
date - a datetime to make a prediction on
return a tuple of the type of article created from the analyzer
"""
return self.__analyzer.predict(date)
示例2: analyze
# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import process_data [as 别名]
def analyze(self, filePath):
"""
Analyze a file.
@param filePath Path to the file.
"""
print("Analyzing book located at: %s" % filePath)
try:
with codecs.open(filePath, 'r', 'utf8') as book:
book_contents = book.read()
except:
raise BookAnalyzerException("Error: Unable to read book.")
analyzer = Analyzer()
analyzer.process_data(book_contents)
analyzer.report_results()