Skip to content

Commit

Permalink
simple gender detection
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneaevans committed Apr 14, 2014
1 parent 840b73c commit b5010f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ To get started with the sprint:

Other tasks:

1. Gender identification - Improve the gender identification in pycon_speakers/pipelines.py
1. Improve the gender identification in pycon_speakers/pipelines.py
2. Chart results


Running the Scrapy Code
Expand Down
15 changes: 6 additions & 9 deletions pycon_speakers/pipelines.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import sexmachine.detector as gender


class GenderPipeline(object):

def __init__(self):
self.detector = gender.Detector()

def process_item(self, item, spider):
item['gender'] = self._infer_gender(item)
firstname = item['name'].split()[0]
item['gender'] = self.detector.get_gender(firstname)
return item

def _infer_gender(self, item):
return 'unknown'


class DefaultsPipeline(object):
"""
Set default values.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Scrapy
SexMachine

0 comments on commit b5010f9

Please sign in to comment.