Example #1
0
    def setUp(self):
        self.SOURCE_TEXT = """In the constant scorekeeping of where tech’s
        power centers are, two trends stand out in Asia: the continued rise of
        China as a tech titan and the slow decline of Japan’s once-mighty
        tech industry.

        Those currents were evident in two recent developments.

        On Thursday, Paul Mozur and Jane Perlez reported that American
        officials had blocked a proposed purchase of a controlling stake in a
        unit of the Dutch electronics company Philips by Chinese investors
        because the United States was fearful the deal would be used to
        further China’s push into microchips.

        At the center of the concerns was a material called gallium nitride,
        which was being used by the Philips unit in light-emitting diodes, but
        which has applications for military and space and can be helpful in
        semiconductors. The report illustrated how American officials have
        come to view China’s large and growing tech industry with misgivings.

        At the same time, Jonathan Soble and Paul Mozur reported that Sharp,
        one of Japan’s large consumer electronics companies and the biggest
        LCD producer, was leaning toward a takeover offer from the Taiwanese
        contract manufacturer Foxconn. The news underlined the decline of
        Japan’s once-famed consumer electronics companies, which have been
        undercut in recent years by lower-cost competition from China and
        South Korea."""
        self.mcq = MCQGenerator(self.SOURCE_TEXT)
Example #2
0
def main():
    news_articles = os.path.join(_NEWS_ARTICLES_DIR, "*.txt")
    output_file = open("output.txt", "w")
    files = glob.glob(news_articles)
    logger.info("Processing {} file(s)".format(len(files)))
    for file_name in files:
        f = open(file_name, encoding='utf-8')
        article = clean_text(f.read())
        # generator = GapFillGenerator(article)
        generator = MCQGenerator(article)
        generator.output_questions(output_file=output_file)
Example #3
0
 def test_should_generate_one_question_with_two_named_ents(self):
     source_sentence =\
         "Those NSA targets were evident in two recent developments " + \
         "in Iran."
     mcq = MCQGenerator(source_sentence)
     self.assertEqual(1, len(mcq.output_questions()))
Example #4
0
 def test_should_generate_zero_questions_with_no_named_ents(self):
     source_sentence =\
         "Those currents were evident in two recent developments."
     mcq = MCQGenerator(source_sentence)
     self.assertFalse(mcq.output_questions())