mirror of
				https://github.com/qurator-spk/dinglehopper.git
				synced 2025-10-31 01:14:16 +01:00 
			
		
		
		
	Fix problem with json encoding
This commit is contained in:
		
							parent
							
								
									9e64c4f0d0
								
							
						
					
					
						commit
						85b784f9a1
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		|  | @ -1,3 +1,4 @@ | |||
| import json | ||||
| import os | ||||
| 
 | ||||
| import click | ||||
|  | @ -55,7 +56,10 @@ def gen_diff_report(gt_in, ocr_in, css_prefix, joiner, none, matches=None): | |||
|         pos = 0 | ||||
|         for ocr_line in ocr_lines_sorted: | ||||
|             if ocr_line.line not in ocr_line_region_id.keys(): | ||||
|                 ocr_line_region_id[ocr_line.line] = ocr_in.segment_id_for_pos(pos) | ||||
|                 try: | ||||
|                     ocr_line_region_id[ocr_line.line] = ocr_in.segment_id_for_pos(pos) | ||||
|                 except AssertionError: | ||||
|                     pass | ||||
|             pos += ocr_line.length | ||||
| 
 | ||||
|         ocr_ids = {None: None} | ||||
|  | @ -159,6 +163,7 @@ def process(gt, ocr, report_prefix, *, metrics="cer,wer", textequiv_level="regio | |||
|         ) | ||||
|     ) | ||||
|     env.filters["json_float"] = json_float | ||||
|     env.filters["json_dumps"] = json.dumps | ||||
| 
 | ||||
|     for report_suffix in (".html", ".json"): | ||||
|         template_fn = "report" + report_suffix + ".j2" | ||||
|  |  | |||
|  | @ -6,6 +6,6 @@ | |||
|     {% if n_characters is not none %}"n_characters": {{ n_characters }},{% endif %} | ||||
|     {% if n_words is not none %}"n_words": {{ n_words }},{% endif %} | ||||
| {% endif %} | ||||
|     "gt": "{{ gt }}", | ||||
|     "ocr": "{{ ocr }}" | ||||
|     "gt": {{ gt|json_dumps }}, | ||||
|     "ocr": {{ ocr|json_dumps }} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue