コード例 #1
0
 def test_index_words_by_strongs(self):
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     strongs_index = maptwtousfm3.indexWordByStrongs(rc)
     expected = {
         "G11610": ["abomination"],
         "G60000": ["abel"],
         "G94600": ["abomination", "test"],
         "H62920": ["abomination", "test"],
         "H34780": ["12tribesofisrael"],
         "H81470": ["12tribesofisrael"],
         "G35880": ["abel"],
         "H84410": ["abomination", "test"],
         "G09760": ["test"],
         "G54430": ["12tribesofisrael"],
         "G24740": ["12tribesofisrael"],
         "H82630": ["test"],
         "H82620": ["abomination", "test"],
         "H76260": ["12tribesofisrael"],
         "H88700": ["abomination", "test"],
         "G14270": ["12tribesofisrael"],
         "H82510": ["abomination", "test"],
         "H01893": ["abel"]
     }
     assert_object_equals_file(
         self, strongs_index,
         os.path.join(self.resources_dir, 'expected_strongs_index.json'))
コード例 #2
0
    def test_index_words(self):
        rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
        index = maptwtousfm3.indexWordsLocation(rc)
        self.assertIn('heb/11/4', index['occurrences'])
        self.assertIn('luk/22/30', index['occurrences'])
        self.assertIn('mat/19/28', index['occurrences'])

        self.assertIn('test', index['occurrences']['mat/19/28'])
        self.assertIn('12tribesofisrael', index['occurrences']['mat/19/28'])
コード例 #3
0
 def test_map_dir(self):
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     out_dir = os.path.join(self.temp_dir, 'mapped_usfm')
     maptwtousfm3.mapDir(os.path.join(self.resources_dir, 'usfm'), rc,
                         out_dir)
     mapped_usfm = read_file(os.path.join(out_dir, '41-MAT.usfm'))
     expected_usfm = read_file(
         os.path.join(self.resources_dir, 'mapped_mat.usfm'))
     self.assertEqual(mapped_usfm, expected_usfm)
コード例 #4
0
 def test_map_usfm_by_occurrence(self):
     usfm = read_file(os.path.join(self.resources_dir, 'usfm/41-MAT.usfm'))
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     words_index = maptwtousfm3.indexWordsLocation(rc)
     category_index = maptwtousfm3.indexWordsCategory(rc)
     mappedUSFM = maptwtousfm3.mapUSFMByOccurrence(
         usfm=usfm,
         words_rc=rc,
         words_index=words_index['occurrences'],
         words_category_index=category_index)
     expected_usfm = read_file(
         os.path.join(self.resources_dir, 'mapped_mat.usfm'))
     self.assertEqual(mappedUSFM, expected_usfm)
コード例 #5
0
 def test_map_usfm_by_global_search(self):
     usfm = read_file(os.path.join(self.resources_dir, 'usfm/41-MAT.usfm'))
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     locations_index = maptwtousfm3.indexWordsLocation(rc)
     strongs_index = maptwtousfm3.indexWordByStrongs(rc)
     category_index = maptwtousfm3.indexWordsCategory(rc)
     mappedUSFM = maptwtousfm3.mapUSFMByGlobalSearch(
         usfm=usfm,
         words_strongs_index=strongs_index,
         words_false_positives_index=locations_index['false_positives'],
         words_category_index=category_index)
     expected_usfm = read_file(
         os.path.join(self.resources_dir, 'mapped_mat_global.usfm'))
     self.assertEqual(mappedUSFM, expected_usfm)
コード例 #6
0
 def test_titus_multiple_word_match(self):
     """
     Ensures we are correctly finding multiple word matches in Titus.
     :return:
     """
     usfm = read_file(os.path.join(self.resources_dir, 'usfm/57-TIT.usfm'))
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     words_index = maptwtousfm3.indexWordsLocation(rc)
     category_index = maptwtousfm3.indexWordsCategory(rc)
     mappedUSFM = maptwtousfm3.mapUSFMByOccurrence(
         usfm=usfm,
         words_rc=rc,
         words_index=words_index['occurrences'],
         words_category_index=category_index)
     expected_usfm = read_file(
         os.path.join(self.resources_dir, 'mapped_tit.usfm'))
     self.assertEqual(mappedUSFM, expected_usfm)
コード例 #7
0
        default=False,
        help=
        'Performs a global word-by-word search in addition to the standard search by occurrences.'
    )
    parser.add_argument('-p',
                        '--phrase',
                        dest='map_phrases',
                        required=False,
                        default='True',
                        help='Groups phrases into USFM milestones.')

    args = parser.parse_args(sys.argv[1:])
    if os.path.isfile(args.output):
        raise Exception('Output must be a directory')

    rc = factory.load(args.words)

    errors_log_file = os.path.join(args.output, 'errors.log')
    if os.path.isfile(errors_log_file):
        os.remove(errors_log_file)
    else:
        os.mkdir(args.output)

    # configure logger
    logger = logging.getLogger(LOGGER_NAME)
    logger.setLevel(logging.WARNING)
    handler = logging.FileHandler(errors_log_file)
    handler.setLevel(logging.WARNING)
    formatter = logging.Formatter("[%(levelname)s] %(message)s")
    handler.setFormatter(formatter)
    logger.addHandler(handler)
コード例 #8
0
 def test_load_strongs(self):
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     strongs = maptwtousfm3.findStrongs('abomination', rc)
     self.assertEqual(
         ['H887', 'H6292', 'H8251', 'H8262', 'H8441', 'G946', 'G11610'],
         strongs)
コード例 #9
0
 def test_index_word_categories(self):
     rc = factory.load(os.path.join(self.resources_dir, 'tw_rc'))
     index = maptwtousfm3.indexWordsCategory(rc)
     self.assertIn('abel', index)
     self.assertEqual('names', index['abel'])