Exemple #1
0
    def testAll(self):
        try:
            cwd = os.getcwd()
            configuration_file = os.path.join(cwd,"config", "app_config.json")
            wiki = Wikipedia('test.input', configuration_file)
            wiki.parse_input()
            wiki.calculate_and_print_answers()
            self.assertEqual(True,True)

        except Exception as e:
         print e
         traceback.print_exc(file=sys.stdout)
         self.assertEqual(True,False)
Exemple #2
0
    def no_answer_question(self):
        try:
            cwd = os.getcwd()
            configuration_file = os.path.join(cwd,"config", "app_config.json")
            wiki = Wikipedia('tests/err', configuration_file)
            wiki.parse_input()
            wiki.calculate_and_print_answers()
            self.assertEqual(False,"test faile")
        except Exception as e:
            print e
            self.assertEqual(True,True)

        try:
            wiki = Wikipedia('tests/test.input8', configuration_file)
            q = QuestionAnswer('why is the earth flat?')
            self.assertEqual( False, q.find_answer(wiki.paragraph, wiki.appconfig) )
        except Exception as e:
            self.assertEqual(False,"test faile")
Exemple #3
0
#!/usr/bin/python

import sys
import os
import traceback
from wikipedia import Wikipedia


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print "usage : python main.py <input-file-name>"
        sys.exit(1)

    input_filename = sys.argv[1]
    cwd = os.getcwd()
    configuration_file = os.path.join(cwd,"config", "app_config.json")
    if not os.path.isfile(configuration_file):
        print "cannot access file ", configuration_file
        sys.exit(1)

    try:
        wiki = Wikipedia(input_filename, configuration_file)        
        wiki.parse_input()
        wiki.calculate_and_print_answers()
    except Exception as e:
         print e
         #traceback.print_exc(file=sys.stdout)