Exemplo n.º 1
0
 def test_should_call_save_svg_structured_document(self):
     structured_document = SvgStructuredDocument(E.svg)
     m = structured_document_saver
     with patch.object(m, 'save_svg_structured_document'
                       ) as save_svg_structured_document_mock:
         save_structured_document(FILE_1, structured_document)
         save_svg_structured_document_mock.assert_called_with(
             FILE_1, structured_document)
Exemplo n.º 2
0
 def test_should_call_save_lxml_structured_document(self):
     structured_document = LxmlStructuredDocument(E.DOCUMENT)
     m = structured_document_saver
     with patch.object(m, 'save_lxml_structured_document'
                       ) as save_lxml_structured_document_mock:
         save_structured_document(FILE_1, structured_document)
         save_lxml_structured_document_mock.assert_called_with(
             FILE_1, structured_document)
def main(argv=None):
    args = parse_args(argv)

    if args.debug:
        logging.getLogger().setLevel('DEBUG')

    color_map = parse_color_map_from_file(args.color_map)
    get_logger().debug('color_map: %s', color_map)

    structured_document = load_structured_document(args.lxml_path, 'rb')

    annotated_images = (load_annotation_image(path, color_map)
                        for path in args.images_path)

    structured_document = annotate_structured_document_using_predicted_images(
        structured_document, annotated_images, tag_scope=args.tag_scope)

    get_logger().info('writing result to: %s', args.output_path)
    save_structured_document(args.output_path, structured_document.root)
def main(argv=None):
    args = parse_args(argv)

    if args.debug:
        logging.getLogger().setLevel('DEBUG')

    structured_document = load_lxml_structured_document(args.lxml_path)

    if args.cv_lxml_path:
        cv_structured_document = load_lxml_structured_document(
            args.cv_lxml_path)
        structured_document = merge_with_cv_structured_document(
            structured_document, cv_structured_document)

    model = load_crf_model(args.crf_model)

    predict_and_annotate_structured_document(structured_document,
                                             model,
                                             tag_scope=args.tag_scope)

    get_logger().info('writing result to: %s', args.output_path)
    save_structured_document(args.output_path, structured_document)