" if shape.shape_type == MSO_SHAPE_TYPE.GROUP:\n",
" for s in shape.shapes:\n",
" visitor(s)\n",
" if shape.shape_type == MSO_SHAPE_TYPE.PICTURE:\n",
" write_image(shape)\n",
"\n",
"def iter_picture_shapes(prs):\n",
" global i,page\n",
" for slide in prs.slides:\n",
" page=[]\n",
" i+=1\n",
" print(i)\n",
" for shape in slide.shapes:\n",
" visitor(shape)\n",
" images.append(page)\n",
"\n",
"iter_picture_shapes(Presentation(filename))\n",
"images"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d528258d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[['Project Speed Cycles Sri Lanka', 'Hero Experience Agency'],\n",
" ['Our Team'],\n",
" ['Purpose',\n",
" '- ',\n",
" 'to find out issues with the current website and ',\n",
" '- to provide recommendations',\n",
" ' in order to rebuild the website to ',\n",
" 'increase sales',\n",
" ' through the website '],\n",
" ['There is cats']]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pptx import Presentation\n",
"\n",
"prs = Presentation(filename)\n",
"\n",
"# text_runs will be populated with a list of strings,\n",
"# one for each text run in presentation\n",
"text_runs = []\n",
"# i=0\n",
"for slide in prs.slides:\n",
"# i+=1\n",
"# print(i)\n",
" text1=[]\n",
" for shape in slide.shapes:\n",
" \n",
" \n",
" if not shape.has_text_frame:\n",
" continue\n",
" for paragraph in shape.text_frame.paragraphs:\n",
" for run in paragraph.runs:\n",
" text1.append(run.text)\n",
" text_runs.append(text1)\n",
"text_runs"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1017a7d1",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Project Speed Cycles Sri Lanka\n",
"[]\n",
"Hero Experience Agency\n",
"[]\n",
"Our Team\n",
"[]\n",
"img/image000.png\n",
"Not Blurry 1298.8642254950346\n",
"img/image001.png\n",
"Not Blurry 1490.0164488611354\n",
"img/image002.png\n",
"Not Blurry 1504.4147008202476\n",
"img/image003.png\n",
"Not Blurry 2057.951858730446\n",
"img/image004.png\n",
"Not Blurry 1810.5483755674986\n",
"Purpose\n",
"[]\n",
"- \n",
"[Match({'ruleId': 'DASH_RULE', 'message': 'Consider using an m-dash in dialogues and enumerations.', 'replacements': ['—'], 'offsetInContext': 0, 'context': '- ', 'offset': 0, 'errorLength': 1, 'category': 'PUNCTUATION', 'ruleIssueType': 'typographical', 'sentence': '-'})]\n",
"to find out issues with the current website and \n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['To'], 'offsetInContext': 0, 'context': 'to find out issues with the current websit...', 'offset': 0, 'errorLength': 2, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'to find out issues with the current website and'})]\n",
"- to provide recommendations\n",
"[Match({'ruleId': 'DASH_RULE', 'message': 'Consider using an m-dash in dialogues and enumerations.', 'replacements': ['—'], 'offsetInContext': 0, 'context': '- to provide recommendations', 'offset': 0, 'errorLength': 1, 'category': 'PUNCTUATION', 'ruleIssueType': 'typographical', 'sentence': '- to provide recommendations'})]\n",
" in order to rebuild the website to \n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['In'], 'offsetInContext': 1, 'context': ' in order to rebuild the website to ', 'offset': 1, 'errorLength': 2, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'in order to rebuild the website to'})]\n",
"increase sales\n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['Increase'], 'offsetInContext': 0, 'context': 'increase sales', 'offset': 0, 'errorLength': 8, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'increase sales'})]\n",
" through the website \n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['Through'], 'offsetInContext': 1, 'context': ' through the website ', 'offset': 1, 'errorLength': 7, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'through the website'})]\n",
"There is cats\n",
"[Match({'ruleId': 'THERE_S_MANY', 'message': 'Did you mean “There are cats”?', 'replacements': ['There are cats'], 'offsetInContext': 0, 'context': 'There is cats', 'offset': 0, 'errorLength': 13, 'category': 'GRAMMAR', 'ruleIssueType': 'grammar', 'sentence': 'There is cats'})]\n",
" if shape.shape_type == MSO_SHAPE_TYPE.GROUP:\n",
" for s in shape.shapes:\n",
" visitor(s)\n",
" if shape.shape_type == MSO_SHAPE_TYPE.PICTURE:\n",
" write_image(shape)\n",
"\n",
"def iter_picture_shapes(prs):\n",
" global i,page\n",
" for slide in prs.slides:\n",
" page=[]\n",
" i+=1\n",
" print(i)\n",
" for shape in slide.shapes:\n",
" visitor(shape)\n",
" images.append(page)\n",
"\n",
"iter_picture_shapes(Presentation(filename))\n",
"images"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "d528258d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[['Project Speed Cycles Sri Lanka', 'Hero Experience Agency'],\n",
" ['Our Team'],\n",
" ['Purpose',\n",
" '- ',\n",
" 'to find out issues with the current website and ',\n",
" '- to provide recommendations',\n",
" ' in order to rebuild the website to ',\n",
" 'increase sales',\n",
" ' through the website '],\n",
" ['There is cats']]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pptx import Presentation\n",
"\n",
"prs = Presentation(filename)\n",
"\n",
"# text_runs will be populated with a list of strings,\n",
"# one for each text run in presentation\n",
"text_runs = []\n",
"# i=0\n",
"for slide in prs.slides:\n",
"# i+=1\n",
"# print(i)\n",
" text1=[]\n",
" for shape in slide.shapes:\n",
" \n",
" \n",
" if not shape.has_text_frame:\n",
" continue\n",
" for paragraph in shape.text_frame.paragraphs:\n",
" for run in paragraph.runs:\n",
" text1.append(run.text)\n",
" text_runs.append(text1)\n",
"text_runs"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1017a7d1",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Project Speed Cycles Sri Lanka\n",
"[]\n",
"Hero Experience Agency\n",
"[]\n",
"Our Team\n",
"[]\n",
"img/image000.png\n",
"Not Blurry 1298.8642254950346\n",
"img/image001.png\n",
"Not Blurry 1490.0164488611354\n",
"img/image002.png\n",
"Not Blurry 1504.4147008202476\n",
"img/image003.png\n",
"Not Blurry 2057.951858730446\n",
"img/image004.png\n",
"Not Blurry 1810.5483755674986\n",
"Purpose\n",
"[]\n",
"- \n",
"[Match({'ruleId': 'DASH_RULE', 'message': 'Consider using an m-dash in dialogues and enumerations.', 'replacements': ['—'], 'offsetInContext': 0, 'context': '- ', 'offset': 0, 'errorLength': 1, 'category': 'PUNCTUATION', 'ruleIssueType': 'typographical', 'sentence': '-'})]\n",
"to find out issues with the current website and \n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['To'], 'offsetInContext': 0, 'context': 'to find out issues with the current websit...', 'offset': 0, 'errorLength': 2, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'to find out issues with the current website and'})]\n",
"- to provide recommendations\n",
"[Match({'ruleId': 'DASH_RULE', 'message': 'Consider using an m-dash in dialogues and enumerations.', 'replacements': ['—'], 'offsetInContext': 0, 'context': '- to provide recommendations', 'offset': 0, 'errorLength': 1, 'category': 'PUNCTUATION', 'ruleIssueType': 'typographical', 'sentence': '- to provide recommendations'})]\n",
" in order to rebuild the website to \n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['In'], 'offsetInContext': 1, 'context': ' in order to rebuild the website to ', 'offset': 1, 'errorLength': 2, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'in order to rebuild the website to'})]\n",
"increase sales\n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['Increase'], 'offsetInContext': 0, 'context': 'increase sales', 'offset': 0, 'errorLength': 8, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'increase sales'})]\n",
" through the website \n",
"[Match({'ruleId': 'UPPERCASE_SENTENCE_START', 'message': 'This sentence does not start with an uppercase letter.', 'replacements': ['Through'], 'offsetInContext': 1, 'context': ' through the website ', 'offset': 1, 'errorLength': 7, 'category': 'CASING', 'ruleIssueType': 'typographical', 'sentence': 'through the website'})]\n",
"There is cats\n",
"[Match({'ruleId': 'THERE_S_MANY', 'message': 'Did you mean “There are cats”?', 'replacements': ['There are cats'], 'offsetInContext': 0, 'context': 'There is cats', 'offset': 0, 'errorLength': 13, 'category': 'GRAMMAR', 'ruleIssueType': 'grammar', 'sentence': 'There is cats'})]\n",