python ngram reducer not returning any output?
Question: I am trying to build a mapreduce job for ngrams of google books. My mapper
works fine when tested locally but the reducer does not returns any value. The
reducer is something like below:

    
    
    #! /usr/bin/env python
    
    import sys
    
    current_word = ''
    word_in_progress = ''
    target_year_count = 0   
    prior_year_count = 0
    target_year = 1999
    
    for line in sys.stdin:
        line = line.strip().split('\t')
        if len(line) !=3:
            continue
        current_word, year, occurances = line
    
        if current_word != word_in_progress:
            if target_year_count > 0:
                if prior_year_count ==0:
                    print '%s\t%s' % (word_in_progress, target_year_count)
        try:
            year = int(year)
        except ValueError:
            continue
        try:
            occurances = int(occurances)
        except ValueError:
            continue
    
        if year == target_year:
            target_year_count += occurances
        if year < target_year:
            prior_year_count += occurances
                print '%s\t%s' % (word_in_progress, target_year_count)
    if target_year_count > 0:
        if prior_year_count ==0:
            print '%s\t%s' % (word_in_progress, target_year_count)
    

And when I type the below command in Ubuntu command line:

    
    
    hduser@bharti-desktop:~/hadoop$ cat /home/hduser/Documents/test1.1.txt | /home/hduser /hadoop/mapper-ngram.py | sort -k1,1 | /home/hduser/hadoop/reducerngram1.py| sort -k2,2n
    

I get nothing. Could somebody tell me what wrong I am doing.


Answer: First thing I'd check:

    
    
    cat /home/hduser/Documents/test1.1.txt | /home/hduser /hadoop/mapper-ngram.py | sort -k1,1 | /home/hduser/hadoop/reducerngram1.py| sort -k2,2n
                                                         ^ # Is this space a typo?
    

Is this space a typo in your post, or did you really run the command that way?
If this is an accurate representation of your command, I'm guessing the
input's not actually getting to your mapper (and therefore nothing will get to
your reducer).

