зеркало из https://github.com/mozilla/inferno.git
This commit is contained in:
Родитель
9b3b349052
Коммит
3b468c5e20
|
@ -14,6 +14,7 @@ Inferno Rule
|
|||
The Inferno map/reduce rule (``inferno/example_rules/election.py``):
|
||||
|
||||
.. literalinclude:: ../inferno/example_rules/election.py
|
||||
:emphasize-lines: 44-49, 58, 66
|
||||
|
||||
Input
|
||||
-----
|
||||
|
@ -51,7 +52,7 @@ Output
|
|||
Contributions by Candidate
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Run the contributions_by_candidate_name map/reduce job::
|
||||
Run the **contributions_by_candidate_name** job::
|
||||
|
||||
diana@ubuntu:~$ inferno -i election.presidential_2012.by_candidate
|
||||
2012-03-19 Processing tags: ['gov:chunk:presidential_campaign_finance']
|
||||
|
@ -87,7 +88,7 @@ The output as a table:
|
|||
Contributions by Occupation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Run the contributions_by_occupation_and_candidate_name map/reduce job::
|
||||
Run the **contributions_by_occupation_and_candidate_name** job::
|
||||
|
||||
diana@ubuntu:~$ inferno -i election.presidential_2012.by_occupation > occupations.csv
|
||||
2012-03-19 Processing tags: ['gov:chunk:presidential_campaign_finance']
|
||||
|
|
|
@ -18,11 +18,6 @@ column_mappings
|
|||
|
||||
TODO
|
||||
|
||||
table
|
||||
-----
|
||||
|
||||
TODO
|
||||
|
||||
parts_preprocess
|
||||
----------------
|
||||
|
||||
|
|
|
@ -5,15 +5,18 @@ from inferno.lib.rule import InfernoRule
|
|||
from inferno.lib.rule import Keyset
|
||||
|
||||
|
||||
# an example field_transform
|
||||
def alphanumeric(val):
|
||||
return re.sub(r'\W+', ' ', val).strip().lower()
|
||||
|
||||
|
||||
# an example parts_preprocess that modifies the map input
|
||||
def count(parts, params):
|
||||
parts['count'] = 1
|
||||
yield parts
|
||||
|
||||
|
||||
def alphanumeric(val):
|
||||
return re.sub(r'\W+', ' ', val).strip().lower()
|
||||
|
||||
|
||||
# an example parts_preprocess that filters the map input
|
||||
def candidate_filter(parts, params):
|
||||
active = [
|
||||
'P20002721', # Santorum, Rick
|
||||
|
@ -26,6 +29,7 @@ def candidate_filter(parts, params):
|
|||
yield parts
|
||||
|
||||
|
||||
# an example parts_postprocess that filters the reduce output
|
||||
def occupation_count_filter(parts, params):
|
||||
if parts['count_occupation_candidate'] > 1000:
|
||||
yield parts
|
||||
|
|
Загрузка…
Ссылка в новой задаче