MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / search

Method search

src/__init__.py:16694–16718  ·  view source on GitHub ↗

Locate 'needle' returning rects or quads.

(self, needle, hit_max=0, quads=1)

Source from the content-addressed store, hash-verified

16692 return val
16693
16694 def search(self, needle, hit_max=0, quads=1):
16695 """Locate 'needle' returning rects or quads."""
16696 val = JM_search_stext_page(self.this, needle)
16697 if not val:
16698 return val
16699 items = len(val)
16700 for i in range(items): # change entries to quads or rects
16701 q = Quad(val[i])
16702 if quads:
16703 val[i] = q
16704 else:
16705 val[i] = q.rect
16706 if quads:
16707 return val
16708 i = 0 # join overlapping rects on the same line
16709 while i < items - 1:
16710 v1 = val[i]
16711 v2 = val[i + 1]
16712 if v1.y1 != v2.y1 or (v1 & v2).is_empty:
16713 i += 1
16714 continue # no overlap on same line
16715 val[i] = v1 | v2 # join rectangles
16716 del val[i + 1] # remove v2
16717 items -= 1 # reduce item count
16718 return val
16719
16720 extractTEXT = extractText
16721

Callers 10

swig_getFunction · 0.80
__init__Method · 0.80
buildFunction · 0.80
get_mupdf_versionFunction · 0.80
search_forMethod · 0.80
get_tessdataFunction · 0.80
search_forFunction · 0.80
checkFunction · 0.80

Calls 2

JM_search_stext_pageFunction · 0.85
QuadClass · 0.85

Tested by 3

checkFunction · 0.64