File size: 3,307 Bytes
369a349
 
 
743de20
c754616
743de20
e78e45b
743de20
 
 
 
 
8400f85
743de20
 
 
 
c754616
743de20
c754616
743de20
c754616
743de20
c754616
 
 
 
 
743de20
c754616
 
 
 
 
 
743de20
 
c754616
 
 
 
 
 
 
743de20
 
c754616
 
 
 
 
 
 
 
 
 
 
 
 
743de20
c754616
 
 
 
 
 
 
 
 
743de20
c754616
 
 
 
 
 
 
 
 
743de20
c754616
 
 
 
 
 
4ee3288
 
 
2f16975
4ee3288
19457ec
e78e45b
 
 
39bf55d
 
19457ec
6decdc5
 
8c1bc7e
b43c9d6
289ba75
 
39bf55d
 
289ba75
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import streamlit as st 
import nltk 
from nltk.corpus import words

st.title("Word Game Solver") 

@st.cache # cache download processes so they only execute once with same inputs
def download():
    nltk.download('words')
download()


[a,b,c,d,e,f,g] = st.columns(7)

with a:
    first_letter = st.text_input(label="1st",value = 'a')
with b:
    second_letter = st.text_input(label="2nd", value = 'e')
with c:
    third_letter = st.text_input(label="3rd", value = 'i')
with d:
    fourth_letter = st.text_input(label="4th", value = 'o')
with e:
    fifth_letter = st.text_input(label="5th", value = 'u')
with f:
    sixth_letter = st.text_input(label="6th", value = '')
with g:
    seventh_letter = st.text_input(label="7th", value = '')

clue2 = first_letter+second_letter
clue3 = first_letter+second_letter+third_letter
clue4 = first_letter+second_letter+third_letter+fourth_letter
clue5 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter
clue6 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter+sixth_letter 
clue7 = first_letter+second_letter+third_letter+fourth_letter+fifth_letter+sixth_letter+seventh_letter 

st.markdown("### clue")
st.write(clue2)
st.write(clue3)
st.write(clue4)
st.write(clue5)
st.write(clue6)
st.write(clue7)

exclusions = st.text_input(label="exclusions")

clue_result2 = []
clue_result3 = []
clue_result4 = []
clue_result5 = []
clue_result6 = []
clue_result7 = []

two_letters = [word for word in words.words() if len(word)==2 ]
three_letters = [word for word in words.words() if len(word)==3 ]
four_letters = [word for word in words.words() if len(word)==4 ]
five_letters = [word for word in words.words() if len(word)==5 ]
six_letters = [word for word in words.words() if len(word)==6 ]
seven_letters = [word for word in words.words() if len(word)==7 ]

for word in two_letters:
 if all(c in word for c in clue2) and not any(c in word for c in exclusions):
   clue_result2.append(word)
for word in three_letters:
 if all(c in word for c in clue3) and not any(c in word for c in exclusions):
   clue_result3.append(word)
for word in four_letters:
 if all(c in word for c in clue4) and not any(c in word for c in exclusions):
   clue_result4.append(word)
for word in five_letters:
 if all(c in word for c in clue5) and not any(c in word for c in exclusions):
   clue_result5.append(word)
for word in six_letters:
 if all(c in word for c in clue6) and not any(c in word for c in exclusions):
   clue_result6.append(word)
for word in seven_letters:
 if all(c in word for c in clue7) and not any(c in word for c in exclusions):
   clue_result7.append(word)
   

st.write(clue_result2)
st.write(clue_result3)
st.write(clue_result4)
st.write(clue_result5)
st.write(clue_result6)
st.write(clue_result7) 
  
  
import requests
from bs4 import BeautifulSoup as soup
import lxml
import lxml.etree as xml


@st.cache # cache download processes so they only execute once with same inputs
def define(word):
  url = f'https://www.dictionary.com/browse/{word}?s=t'
  r=requests.get(url)
  s = soup(r.content, features="lxml")
  for tag in s.find_all("meta"):
    if tag.get("property", None) == "og:description":
        content = tag.get("content", None)
        return content

    
for word in clue_result7:
  content = define(word)
  st.write(content)