mirror of
				https://github.com/qurator-spk/ocrd_repair_inconsistencies.git
				synced 2025-10-31 00:44:13 +01:00 
			
		
		
		
	pylint karma
This commit is contained in:
		
							parent
							
								
									e16438a377
								
							
						
					
					
						commit
						d5094ee42b
					
				
					 3 changed files with 33 additions and 11 deletions
				
			
		
							
								
								
									
										24
									
								
								.pylintrc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.pylintrc
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,24 @@ | ||||||
|  | [MASTER] | ||||||
|  | 
 | ||||||
|  | [MESSAGES CONTROL] | ||||||
|  | disable = | ||||||
|  |     ungrouped-imports, | ||||||
|  |     bad-continuation, | ||||||
|  |     missing-docstring, | ||||||
|  |     no-self-use, | ||||||
|  |     superfluous-parens, | ||||||
|  |     invalid-name, | ||||||
|  |     line-too-long, | ||||||
|  |     too-many-arguments, | ||||||
|  |     too-many-branches, | ||||||
|  |     too-many-statements, | ||||||
|  |     too-many-locals, | ||||||
|  |     too-few-public-methods, | ||||||
|  |     wrong-import-order, | ||||||
|  |     duplicate-code | ||||||
|  | 
 | ||||||
|  | # allow indented whitespace (as required by interpreter): | ||||||
|  | no-space-check=empty-line | ||||||
|  | 
 | ||||||
|  | # allow non-snake-case identifiers: | ||||||
|  | good-names=n,i | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| import json | import json | ||||||
| from pkg_resources import resource_string | from pkg_resources import resource_string | ||||||
| 
 | 
 | ||||||
| OCRD_TOOL = json.loads(resource_string(__name__, 'ocrd-tool.json').decode('utf8')) | OCRD_TOOL = json.loads(resource_string(__name__, 'ocrd-tool.json').decode('utf8')) | ||||||
|  |  | ||||||
|  | @ -64,7 +64,7 @@ class RepairInconsistencies(Processor): | ||||||
|                              page_id, region.id, textLineOrder) |                              page_id, region.id, textLineOrder) | ||||||
|                     continue |                     continue | ||||||
| 
 | 
 | ||||||
|                 _fix_segment(region, page_id, reverse=textLineOrder=='bottom-to-top') |                 _fix_segment(region, page_id, reverse=(textLineOrder == 'bottom-to-top')) | ||||||
| 
 | 
 | ||||||
|                 lines = region.get_TextLine() |                 lines = region.get_TextLine() | ||||||
|                 for line in lines: |                 for line in lines: | ||||||
|  | @ -80,7 +80,7 @@ class RepairInconsistencies(Processor): | ||||||
|                                  page_id, line.id, readingDirection) |                                  page_id, line.id, readingDirection) | ||||||
|                         continue |                         continue | ||||||
|                      |                      | ||||||
|                     _fix_segment(line, page_id, reverse=readingDirection=='right-to-left') |                     _fix_segment(line, page_id, reverse=(readingDirection == 'right-to-left')) | ||||||
| 
 | 
 | ||||||
|                     words = line.get_Word() |                     words = line.get_Word() | ||||||
|                     for word in words: |                     for word in words: | ||||||
|  | @ -96,7 +96,7 @@ class RepairInconsistencies(Processor): | ||||||
|                                      page_id, word.id, readingDirection) |                                      page_id, word.id, readingDirection) | ||||||
|                             continue |                             continue | ||||||
| 
 | 
 | ||||||
|                         _fix_segment(word, page_id, reverse=readingDirection=='right-to-left') |                         _fix_segment(word, page_id, reverse=(readingDirection == 'right-to-left')) | ||||||
| 
 | 
 | ||||||
|             file_id = input_file.ID.replace(self.input_file_grp, self.output_file_grp) |             file_id = input_file.ID.replace(self.input_file_grp, self.output_file_grp) | ||||||
|             if file_id == input_file.ID: |             if file_id == input_file.ID: | ||||||
|  | @ -124,10 +124,8 @@ def get_text(thing, joiner=''): | ||||||
|         texts = [_get_text_for_one(part) for part in thing] |         texts = [_get_text_for_one(part) for part in thing] | ||||||
|         if all(texts): |         if all(texts): | ||||||
|             return joiner.join(texts) |             return joiner.join(texts) | ||||||
|         else: |         return None | ||||||
|             return None |     return _get_text_for_one(thing) | ||||||
|     else: |  | ||||||
|         return _get_text_for_one(thing) |  | ||||||
| 
 | 
 | ||||||
| def _fix_segment(segment, page_id, reverse=False): | def _fix_segment(segment, page_id, reverse=False): | ||||||
|     """Fix order of child elements of (region/line/word) segment.""" |     """Fix order of child elements of (region/line/word) segment.""" | ||||||
|  | @ -160,8 +158,7 @@ def _fix_segment(segment, page_id, reverse=False): | ||||||
|             polygon = Polygon(polygon_from_points(child.get_Coords().points)) |             polygon = Polygon(polygon_from_points(child.get_Coords().points)) | ||||||
|             if horizontal: |             if horizontal: | ||||||
|                 return polygon.centroid.x |                 return polygon.centroid.x | ||||||
|             else: |             return polygon.centroid.y | ||||||
|                 return polygon.centroid.y |  | ||||||
|         sorted_children = sorted(children, reverse=reverse, key=polygon_position) |         sorted_children = sorted(children, reverse=reverse, key=polygon_position) | ||||||
|         sorted_concat_text = get_text(sorted_children, joiner) |         sorted_concat_text = get_text(sorted_children, joiner) | ||||||
|          |          | ||||||
|  | @ -170,7 +167,8 @@ def _fix_segment(segment, page_id, reverse=False): | ||||||
|             LOG.info('Fixing element order of page "%s" segment "%s"', page_id, segment.id) |             LOG.info('Fixing element order of page "%s" segment "%s"', page_id, segment.id) | ||||||
|             adoption(sorted_children) |             adoption(sorted_children) | ||||||
|         else: |         else: | ||||||
|             LOG.debug('Resorting children of page "%s" segment "%s" from %s to %s does not suffice to turn "%s" into "%s"', |             LOG.debug('Resorting children of page "%s" segment "%s" from %s to %s' + | ||||||
|  |                       'does not suffice to turn "%s" into "%s"', | ||||||
|                       page_id, segment.id, |                       page_id, segment.id, | ||||||
|                       str([seg.id for seg in children]), |                       str([seg.id for seg in children]), | ||||||
|                       str([seg.id for seg in sorted_children]), |                       str([seg.id for seg in sorted_children]), | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue