import os
import csv
from tweedr.corpora import DatasourceI
from tweedr.lib import globfirst

corpora_root = os.path.expanduser(os.environ.get('CORPORA', '~/corpora'))


class CSVDatasouce(DatasourceI):
    filepath = None
    label_column = 'category'
    text_column = 'text'

    def __iter__(self):
        with open(self.filepath) as fp:
            for row in csv.DictReader(fp):
                yield row[self.label_column], row[self.text_column]


class a121571_datasource(CSVDatasouce):
    '''
    Counts:

     46 People missing, found or seen
    130 Unknown
    137 Casualties and damage
    204 Donations of money, goods or services
    280 Information source
    436 Caution and advice
    '''
    # TODO: come up with a better name
    filepath = globfirst('**/a121571.csv', root=corpora_root)
    label_column = 'choose_one'
    text_column = 'text'


if __name__ == '__main__':
    for label, text in a121571_datasource():
        print label, '\t', text

@@ -449,16 +449,344 @@
 lumn%5D%0A%0A%0A
+class a131709_datasource(CSVDatasouce):%0A    '''%0A    Counts:%0A%0A     94 Other%0A    265 Informative (Direct)%0A    469 Informative (Indirect)%0A    762 Informative (Direct or Indirect)%0A    794 Personal only%0A    '''%0A    filepath = globfirst('**/a131709.csv', root=corpora_root)%0A    label_column = 'choose_one'%0A    text_column = 'tweet'%0A%0A%0A
 class a1
@@ -1190,16 +1190,1289 @@
 text'%0A%0A%0A
+class a122047_datasource(CSVDatasouce):%0A    '''%0A    Counts:%0A%0A      3 A shelter is open or available%0A     27 A siren has been heard%0A     99 A tornado sighting/touchdown has been reported%0A    102 Other%0A    207 A tornado/thunderstorm warning has been issued or has been lifted%0A    '''%0A    filepath = globfirst('**/a122047.csv', root=corpora_root)%0A    label_column = 'type_of_advice_or_caution'%0A    text_column = 'text'%0A%0A%0Aclass a126730_datasource(CSVDatasouce):%0A    '''%0A    Counts:%0A%0A     1 Both people and infrastructure%0A     1 People: injured%0A     2 People: injured and dead%0A    12 Not damage-related%0A    17 Infrastructure (building, bridge, road, etc.) damaged%0A    47 Not specified (maybe people or infrastructure)%0A    58 People: dead%0A    '''%0A    filepath = globfirst('**/a126730.csv', root=corpora_root)%0A    label_column = 'people_or_infrastructure'%0A    text_column = 'text'%0A%0A%0Aclass a126728_datasource(CSVDatasouce):%0A    '''%0A    Counts:%0A%0A      2 Discount (rebate/special offer)%0A      3 Blood%0A      3 Equipment (machine/generator/pump/etc.)%0A      6 Food%0A      7 Shelter%0A     11 Volunteers/work%0A     53 Money%0A    119 Other, or not specified%0A    '''%0A    filepath = globfirst('**/a126728.csv', root=corpora_root)%0A    label_column = 'type_of_donation'%0A    text_column = 'text'%0A%0A%0A
 if __nam

Add a few more files and their primary classification counts.