2014-12-19 3 views
0

Google 도서의 ngrams에 대한 mapreduce 작업을 구축하려고합니다. 내 매퍼는 로컬에서 테스트 할 때 잘 작동하지만 감속기는 값을 반환하지 않습니다. 감속기는 뭔가 다음과 같다 :파이썬 ngram 감속기가 출력을 반환하지 않습니까?

#! /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) 

내가 우분투 명령 줄에서 다음 명령을 입력 할 때 :

[email protected]:~/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 

을 나는 아무것도 얻을 수 없다. 누군가 내가하고있는 잘못을 말해 줄 수 있습니까? 내가 확인할 것

답변

0

우선 :

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? 

이 공간이 게시물에 오타, 아니면 정말 그런 식으로 명령을 실행 했습니까? 이것이 당신의 명령을 정확하게 표현했다면, 나는 당신의 매퍼에게 실제로 들어 가지 않은 입력을 추측하고 있습니다. 그러므로 당신의 감속기에 도달 할 것이 없습니다.

관련 문제