나는 사용자 쿼리와 관련하여 순위가 매겨진 문서를 반환하는 python으로 문서 검색 엔진을 구축하고 있습니다. PowerPoint 파일도 포함 된 문서 모음이 있습니다. PPT의 경우 결과 페이지에서 처음 몇 슬라이드 제목을 표시하여 사용자에게 명확한 그림을 제공하고 싶습니다 (Google 검색에서와 같이).python-pptx 슬라이드 제목에서 텍스트 추출
기본적으로 저는 파이썬을 사용하여 PPT 파일에서 슬라이드 제목의 텍스트를 추출하고 싶습니다. 나는 python-pptx 패키지를 사용하고 있습니다. 현재 내 구현이
from pptx import Presentation
prs = Presentation(filepath) # load the ppt
slide_titles = [] # container foe slide titles
for slide in prs.slides: # iterate over each slide
title_shape = slide.shapes[0] # consider the zeroth indexed shape as the title
if title_shape.has_text_frame: # is this shape has textframe attribute true then
# check if the slide title already exists in the slide_title container
if title_shape.text.strip(""" [email protected]#$%^&*)(_-+=}{][:;<,>.?"'/<,""")+ '. ' not in slide_titles:
slide_titles.append(title_shape.text.strip(""" [email protected]#$%^&*)(_-+=}{][:;<,>.?"'/<,""")+ '. ')
같이 보입니다하지만 당신은 내가 매번 분명 사실이 아니다 슬라이드 제목으로 각 슬라이드에 제로 인덱스 형태를 가정하고 볼 수 있습니다. 이 작업을 수행하는 방법에 대한 아이디어가 있습니까?
미리 감사드립니다.