# Path: tweedr/api/pipeline.py
# class Pipeline(object):
#     def __init__(self, *mappers):
#     def __call__(self, payload):
# 
# Path: tweedr/api/mappers/basic.py
# class EmptyLineFilter(Mapper):
# class JSONParser(Mapper):
# class IgnoreMetadata(Mapper):
# class TweetStandardizer(Mapper):
# class LineStream(Mapper):
#     INPUT = StringProtocol
#     OUTPUT = StringProtocol
#     INPUT = StringProtocol
#     OUTPUT = DictProtocol
#     INPUT = DictProtocol
#     OUTPUT = DictProtocol
#     INPUT = DictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = DictProtocol
#     OUTPUT = None
#     def __call__(self, line):
#     def __call__(self, line):
#     def __call__(self, dict_):
#     def __call__(self, dict_):
#     def __init__(self, stream):
#     def __call__(self, dict_):
# 
# Path: tweedr/api/mappers/similar.py
# class TextCounter(Mapper):
# class FuzzyTextCounter(Mapper):
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     def __init__(self):
#     def __call__(self, dict_):
#     def __init__(self, threshold=0.97):
#     def __call__(self, dict_):
# 
# Path: tweedr/api/mappers/nlp.py
# class POSTagger(Mapper):
# class SequenceTagger(Mapper):
# class DBpediaSpotter(Mapper):
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     def __init__(self):
#     def __call__(self, tweet):
#     def __init__(self):
#     def __call__(self, tweet):
#     def __init__(self, confidence=0.1, support=10):
#     def __call__(self, tweet):
# 
# Path: tweedr/api/mappers/ml.py
# class CorpusClassifier(Mapper):
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     def tokenizer(self, text):
#     def __init__(self, datasource, classifier):
#     def __call__(self, tweet):
# 
# Path: tweedr/corpora/qcri.py
# class a126730_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     Counts:
# 
#      1 Both people and infrastructure
#      1 People: injured
#      2 People: injured and dead
#     12 Not damage-related
#     17 Infrastructure (building, bridge, road, etc.) damaged
#     47 Not specified (maybe people or infrastructure)
#     58 People: dead
#     '''
#     filepath = globfirst('**/a126730.csv', root=corpora_root)
#     label_column = 'people_or_infrastructure'
#     text_column = 'text'
# 
# class a121571_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     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'
# 
# class a126728_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     Counts:
# 
#       2 Discount (rebate/special offer)
#       3 Blood
#       3 Equipment (machine/generator/pump/etc.)
#       6 Food
#       7 Shelter
#      11 Volunteers/work
#      53 Money
#     119 Other, or not specified
#     '''
#     filepath = globfirst('**/a126728.csv', root=corpora_root)
#     label_column = 'type_of_donation'
#     text_column = 'text'
# 
# class a122047_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     Counts:
# 
#       3 A shelter is open or available
#      27 A siren has been heard
#      99 A tornado sighting/touchdown has been reported
#     102 Other
#     207 A tornado/thunderstorm warning has been issued or has been lifted
#     '''
#     filepath = globfirst('**/a122047.csv', root=corpora_root)
#     label_column = 'type_of_advice_or_caution'
#     text_column = 'text'


import argparse
import sys
import logging
from tweedr.api import pipeline
from tweedr.api.mappers import basic, similar, nlp, ml
from tweedr.corpora.qcri import a126730_datasource, a121571_datasource, a126728_datasource, a122047_datasource
from sklearn import linear_model, naive_bayes, neighbors, svm


logger = logging.getLogger(__name__)


def main():
    parser = argparse.ArgumentParser(description='Run tweets from STDIN through the tweedr pipeline, output to STDOUT.')
    parser.add_argument('-v', '--verbose', action='store_true', help='Log extra output')
    opts = parser.parse_args()

    # bump threshold down to show info=20, debug=10, and silly=5 if --verbose is set
    if opts.verbose:
        logger.setLevel('SILLY')

    if sys.stdin.isatty():
        raise IOError('You must provide input via STDIN')

    cli_pipeline = pipeline.Pipeline(
        basic.EmptyLineFilter(),

# Path: tweedr/api/pipeline.py
# class Pipeline(object):
#     def __init__(self, *mappers):
#     def __call__(self, payload):
# 
# Path: tweedr/api/mappers/basic.py
# class EmptyLineFilter(Mapper):
# class JSONParser(Mapper):
# class IgnoreMetadata(Mapper):
# class TweetStandardizer(Mapper):
# class LineStream(Mapper):
#     INPUT = StringProtocol
#     OUTPUT = StringProtocol
#     INPUT = StringProtocol
#     OUTPUT = DictProtocol
#     INPUT = DictProtocol
#     OUTPUT = DictProtocol
#     INPUT = DictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = DictProtocol
#     OUTPUT = None
#     def __call__(self, line):
#     def __call__(self, line):
#     def __call__(self, dict_):
#     def __call__(self, dict_):
#     def __init__(self, stream):
#     def __call__(self, dict_):
# 
# Path: tweedr/api/mappers/similar.py
# class TextCounter(Mapper):
# class FuzzyTextCounter(Mapper):
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     def __init__(self):
#     def __call__(self, dict_):
#     def __init__(self, threshold=0.97):
#     def __call__(self, dict_):
# 
# Path: tweedr/api/mappers/nlp.py
# class POSTagger(Mapper):
# class SequenceTagger(Mapper):
# class DBpediaSpotter(Mapper):
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     def __init__(self):
#     def __call__(self, tweet):
#     def __init__(self):
#     def __call__(self, tweet):
#     def __init__(self, confidence=0.1, support=10):
#     def __call__(self, tweet):
# 
# Path: tweedr/api/mappers/ml.py
# class CorpusClassifier(Mapper):
#     INPUT = TweetDictProtocol
#     OUTPUT = TweetDictProtocol
#     def tokenizer(self, text):
#     def __init__(self, datasource, classifier):
#     def __call__(self, tweet):
# 
# Path: tweedr/corpora/qcri.py
# class a126730_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     Counts:
# 
#      1 Both people and infrastructure
#      1 People: injured
#      2 People: injured and dead
#     12 Not damage-related
#     17 Infrastructure (building, bridge, road, etc.) damaged
#     47 Not specified (maybe people or infrastructure)
#     58 People: dead
#     '''
#     filepath = globfirst('**/a126730.csv', root=corpora_root)
#     label_column = 'people_or_infrastructure'
#     text_column = 'text'
# 
# class a121571_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     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'
# 
# class a126728_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     Counts:
# 
#       2 Discount (rebate/special offer)
#       3 Blood
#       3 Equipment (machine/generator/pump/etc.)
#       6 Food
#       7 Shelter
#      11 Volunteers/work
#      53 Money
#     119 Other, or not specified
#     '''
#     filepath = globfirst('**/a126728.csv', root=corpora_root)
#     label_column = 'type_of_donation'
#     text_column = 'text'
# 
# class a122047_datasource(CSVDatasouce):
#     # from joplin/
#     '''
#     Counts:
# 
#       3 A shelter is open or available
#      27 A siren has been heard
#      99 A tornado sighting/touchdown has been reported
#     102 Other
#     207 A tornado/thunderstorm warning has been issued or has been lifted
#     '''
#     filepath = globfirst('**/a122047.csv', root=corpora_root)
#     label_column = 'type_of_advice_or_caution'
#     text_column = 'text'


# Path: tweedr/cli/pipeline.py
import argparse
import sys
import logging
from tweedr.api import pipeline
from tweedr.api.mappers import basic, similar, nlp, ml
from tweedr.corpora.qcri import a126730_datasource, a121571_datasource, a126728_datasource, a122047_datasource
from sklearn import linear_model, naive_bayes, neighbors, svm



logger = logging.getLogger(__name__)


def main():
    parser = argparse.ArgumentParser(description='Run tweets from STDIN through the tweedr pipeline, output to STDOUT.')
    parser.add_argument('-v', '--verbose', action='store_true', help='Log extra output')
    opts = parser.parse_args()

    # bump threshold down to show info=20, debug=10, and silly=5 if --verbose is set
    if opts.verbose:
        logger.setLevel('SILLY')

    if sys.stdin.isatty():
        raise IOError('You must provide input via STDIN')

    cli_pipeline = pipeline.Pipeline(
        basic.EmptyLineFilter(),

        basic.JSONParser(),