ddg image + layouts
parent
af85f78f1f
commit
7ef9fd8d01
Binary file not shown.
@ -0,0 +1,37 @@
|
|||||||
|
import nltk
|
||||||
|
|
||||||
|
with open('speech.txt','r') as result:
|
||||||
|
r = result.read()
|
||||||
|
|
||||||
|
r = r.replace('<span class="interim"></span>','').replace('\n','. ')
|
||||||
|
|
||||||
|
l=nltk.word_tokenize(r)
|
||||||
|
pos = nltk.pos_tag(l)
|
||||||
|
|
||||||
|
html = '''
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="pagedjs_files/interface.css">
|
||||||
|
<script src="pagedjs_files/paged.polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" href="styles/1.css">
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Booklet</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
'''
|
||||||
|
|
||||||
|
for x in pos:
|
||||||
|
if x[0] == '.':
|
||||||
|
html += "<span class='dot'>.</span><br> \n"
|
||||||
|
else:
|
||||||
|
html += "<span class='"+x[1]+"'> "+x[0]+"</span>\n"
|
||||||
|
|
||||||
|
|
||||||
|
html += '''</body>
|
||||||
|
</html>'''
|
||||||
|
|
||||||
|
html = html.replace(' .','.').replace(" '", "'")
|
||||||
|
|
||||||
|
with open('index.html','w') as index:
|
||||||
|
index.write(html)
|
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="pagedjs_files/interface.css">
|
||||||
|
<script src="pagedjs_files/paged.polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" href="styles/3.css">
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Booklet</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<span>ok let's talk in English for awhile what are we eating</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIP.URkqiGHddaNVnvoUtMflQQHaF0&pid=Api'>
|
||||||
|
<span>or not so it is starting again</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIP.w2KDA__F4lQ1NyTt5FOjIgAAAA&pid=Api'>
|
||||||
|
<span>ok navigate</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIF.y9XMU%2b2gdAWMj7VXDE%2ft%2fQ&pid=Api'>
|
||||||
|
<span>you need to rest sometimes</span>
|
||||||
|
<img src='https://tse4.mm.bing.net/th?id=OIP.GbFGas-ayDWMUd_9vgedSwHaGO&pid=Api'>
|
||||||
|
<span>also implemented that implementing</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIF.GJKQxrJERpdrEixc86Aylg&pid=Api'>
|
||||||
|
<span>he's a sentence and we are not interested</span>
|
||||||
|
<img src='https://tse2.mm.bing.net/th?id=OIP.B8V15Vgwb4WSIBCh_DBKAAHaEK&pid=Api'>
|
||||||
|
<span>remember</span>
|
||||||
|
<img src='https://tse4.mm.bing.net/th?id=OIP.FIpqGxb0o5Qhs7F6FsmLUwHaJ4&pid=Api'>
|
||||||
|
<span>so basically sentence</span>
|
||||||
|
<img src='https://tse4.mm.bing.net/th?id=OIP.R-Aq7zQgyXkEkqHsRpd_fQHaK5&pid=Api'>
|
||||||
|
<span>where is to go a couple and then you put the adult</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIP.-zezO3MYsykMDFXKr5BN4gHaFT&pid=Api'>
|
||||||
|
<span>a bit easier to understand</span>
|
||||||
|
<img src='https://tse2.mm.bing.net/th?id=OIP.dAOU1dmcC7DcOHjdZWnsOAHaFj&pid=Api'>
|
||||||
|
<span>actually maybe people just don't just</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIP.lN80mz6v0-Og5Hy4rBFDBgHaFj&pid=Api'>
|
||||||
|
<span>I'm just thinking it's not the centres don't put the dot and just put a couple</span>
|
||||||
|
<img src='https://tse2.mm.bing.net/th?id=OIP.soE-jIhLUlXXcsImI9dSAgHaDE&pid=Api'>
|
||||||
|
<span>because then</span>
|
||||||
|
<img src='https://tse4.mm.bing.net/th?id=OIP._isREjX53ak2ahph2VOozgHaIM&pid=Api'>
|
||||||
|
<span>they are talking they are a booklet but they are not writing</span>
|
||||||
|
<img src='https://tse2.mm.bing.net/th?id=OIP.-utvaIFVP4SIM9E9Am3efAHaEZ&pid=Api'>
|
||||||
|
<span>so it is just fine</span>
|
||||||
|
<img src='https://tse3.mm.bing.net/th?id=OIP.6d-LRDAm986tLKsRdmxAFwHaC_&pid=Api'>
|
||||||
|
<span>so are you done</span>
|
||||||
|
<img src='https://tse1.mm.bing.net/th?id=OIF.GUCE7OkP722hk6eZcjJckQ&pid=Api'>
|
||||||
|
<span>and now is f***** up</span>
|
||||||
|
<img src='https://tse4.mm.bing.net/th?id=OIP.Z_JLWGz4XfBuc0lzMmTUggHaEQ&pid=Api'>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,71 @@
|
|||||||
|
import DuckDuckGoImages as ddg
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
with open('speech.txt','r') as speech:
|
||||||
|
qq = speech.readlines()
|
||||||
|
|
||||||
|
html = ''
|
||||||
|
|
||||||
|
html = '''
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="pagedjs_files/interface.css">
|
||||||
|
<script src="pagedjs_files/paged.polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" href="styles/3.css">
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Booklet</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
'''
|
||||||
|
|
||||||
|
if os.path.isdir('./images/') is True:
|
||||||
|
shutil.rmtree('./images/')
|
||||||
|
|
||||||
|
os.mkdir('./images/')
|
||||||
|
|
||||||
|
|
||||||
|
for q in qq:
|
||||||
|
if q == '''<span class="interim"></span>''':
|
||||||
|
continue
|
||||||
|
|
||||||
|
qDDG = q.replace(' ','+')
|
||||||
|
qBinded = q.replace(' ','')
|
||||||
|
print(qDDG)
|
||||||
|
qBinded = qBinded.replace("\n","")
|
||||||
|
os.mkdir(f'./images/{qBinded}')
|
||||||
|
ddg.download(qDDG, folder= f"./images/{qBinded}/", max_urls=10, thumbnails=True)
|
||||||
|
normalize = os.listdir(f"./images/{qBinded}/")
|
||||||
|
|
||||||
|
print(len(os.listdir(f"./images/{qBinded}/")))
|
||||||
|
|
||||||
|
if len(os.listdir(f"./images/{qBinded}/")) == 0:
|
||||||
|
html += f'<span class="{qBinded}">{q}</span><br><br>'
|
||||||
|
os.rmdir(f'./images/{qBinded}/')
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
print('NORMALIZE', normalize)
|
||||||
|
normalize = normalize[0]
|
||||||
|
|
||||||
|
splitExtension = os.path.splitext(normalize)
|
||||||
|
print('ESTENSIONE', splitExtension)
|
||||||
|
|
||||||
|
|
||||||
|
os.rename(f'./images/{qBinded}/{normalize}', f'./images/{qBinded}/{qBinded}')
|
||||||
|
os.replace(f'./images/{qBinded}/{qBinded}', f'./images/{qBinded}.jpg')
|
||||||
|
shutil.rmtree(f'./images/{qBinded}/')
|
||||||
|
|
||||||
|
html += f"""<span class="{qBinded}">{q}</span>"""
|
||||||
|
html += f"""<span><img src="./images/{qBinded}.jpg"></span>"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
html += '''</body>
|
||||||
|
</html>'''
|
||||||
|
|
||||||
|
html = html.replace(' .','.').replace(" '", "'")
|
||||||
|
|
||||||
|
with open('picindex.html','w') as index:
|
||||||
|
index.write(html)
|
@ -0,0 +1,49 @@
|
|||||||
|
import DuckDuckGoImages as ddg
|
||||||
|
from duckduckgo_images_api import search
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
with open('speech.txt','r') as speech:
|
||||||
|
qq = speech.readlines()
|
||||||
|
|
||||||
|
html = ''
|
||||||
|
|
||||||
|
html = '''
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="pagedjs_files/interface.css">
|
||||||
|
<script src="pagedjs_files/paged.polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" href="styles/3.css">
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Booklet</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for q in qq:
|
||||||
|
q = q.strip()
|
||||||
|
if q == '''<span class="interim"></span>''':
|
||||||
|
continue
|
||||||
|
|
||||||
|
q = q.replace("\n","")
|
||||||
|
|
||||||
|
qDDG = q.replace(' ','+')
|
||||||
|
|
||||||
|
results = search(q, max_results=1)
|
||||||
|
r = results["results"][0]["thumbnail"]
|
||||||
|
|
||||||
|
html += f"""<span> {q} </span>\n"""
|
||||||
|
html += f"""<img src='{r}'>\n"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
html += '''</body>
|
||||||
|
</html>'''
|
||||||
|
|
||||||
|
html = html.replace(' .','.').replace(" '", "'")
|
||||||
|
|
||||||
|
with open('nuovo.html','w') as index:
|
||||||
|
index.write(html)
|
Loading…
Reference in New Issue