def should_work_end_to_end():
    with mock_console_io(
            tabify('''brendan torsten
                         davidbowie kim
                         davidbowie omid
                         davidbowie ziggy
                         kim davidbowie
                         kim torsten
                         mick ziggy''')) as mock:
        main()
    reduce_out = mock[0]
    with mock_console_io(reduce_out) as mock:
        print_main()
    assert mock[0] == tabify('''brendan torsten
davidbowie kim omid ziggy
kim davidbowie torsten
mick ziggy
''')
def should_work_end_to_end():
    with mock_console_io(tabify('''brendan torsten
                         davidbowie kim
                         davidbowie omid
                         davidbowie ziggy
                         kim davidbowie
                         kim torsten
                         mick ziggy''')) as mock:
        main()
    reduce_out = mock[0]
    with mock_console_io(reduce_out) as mock:
        print_main()
    assert mock[0] == tabify(
'''brendan torsten
davidbowie kim omid ziggy
kim davidbowie torsten
mick ziggy
''')
    
Beispiel #3
0
import mapper
import reducer
import os

WORKING_DIR = os.path.dirname(__file__)

IN_FILE = os.path.join(WORKING_DIR, "..", "data", "training.txt")

EVALUATE_SCRIPT = os.path.join(WORKING_DIR, "evaluate.py")

str = open(IN_FILE).readlines()
stream = mapper.main(str)
# #print stream
#
output = reducer.main(stream)
#
WEIGHTS_PATH = os.path.join(WORKING_DIR, "weights.txt")
with open(WEIGHTS_PATH, 'w') as weight_f:
    weight_f.write(output)
# #print output

# Usage: evaluate.py weights.txt
# test_data.txt test_labels.txt folder_with_mapper
command_line = ["python", EVALUATE_SCRIPT]
command_line.append(WEIGHTS_PATH)
command_line.append(os.path.join(WORKING_DIR, "test_data.txt"))
command_line.append(os.path.join(WORKING_DIR, "test_labels.txt"))
command_line.append(WORKING_DIR)

command_line = " ".join(command_line)
print command_line
Beispiel #4
0
 def test_reducer(self):
     with open('test/output_mapper.txt','r') as in_f:
         with open('test/output.txt','w') as out_f:
             reducer.main(InputFile = in_f,OutputFile=out_f)
import reducer
import os


WORKING_DIR = os.path.dirname(__file__)

IN_FILE = os.path.join(WORKING_DIR, "..", "data", "training.txt")

EVALUATE_SCRIPT = os.path.join(WORKING_DIR, "evaluate.py")


str = open(IN_FILE).readlines()
stream = mapper.main(str)
# #print stream
#
output = reducer.main(stream)
#
WEIGHTS_PATH = os.path.join(WORKING_DIR, "weights.txt")
with open(WEIGHTS_PATH, "w") as weight_f:
    weight_f.write(output)
# #print output


# Usage: evaluate.py weights.txt
# test_data.txt test_labels.txt folder_with_mapper
command_line = ["python", EVALUATE_SCRIPT]
command_line.append(WEIGHTS_PATH)
command_line.append(os.path.join(WORKING_DIR, "test_data.txt"))
command_line.append(os.path.join(WORKING_DIR, "test_labels.txt"))
command_line.append(WORKING_DIR)
 def test_1(self):
     self.assertEqual(reducer.main(), None)