KwabsHug commited on
Commit
32962aa
1 Parent(s): c7cc4f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -1
app.py CHANGED
@@ -5,6 +5,8 @@ import nltk
5
  from nltk.corpus import wordnet
6
  import wikipedia
7
  import re
 
 
8
 
9
  nltk.download('maxent_ne_chunker') #Chunker
10
  nltk.download('stopwords') #Stop Words List (Mainly Roman Languages)
@@ -209,6 +211,36 @@ def merge_lines(roman_file, w4w_file, full_mean_file, macaronic_file):
209
  def TTSforListeningPractice(text):
210
  return "not finished"
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  with gr.Blocks() as lliface:
213
  with gr.Tab("Welcome "):
214
  gr.HTML("""<h1> Spaces Test - Still Undercontruction </h1> <p> You only learn when you convert things you dont know to known --> Normally Repetition is the only reliable method for everybody </p>
@@ -227,7 +259,12 @@ with gr.Blocks() as lliface:
227
  gr.Interface(fn=keep_nouns_verbs, inputs=["text"], outputs="text", title="Noun and Verbs only (Plus punctuation)")
228
  with gr.Tab("Timing Practice - Repitition"):
229
  gr.HTML("<p>Run from it, Dread it, Repitition is inevitable - Thanos</p> <p>Next Milestone is Turning this interface handsfree</p>")
230
- gr.HTML("""<iframe height="1200" style="width: 100%;" scrolling="no" title="Memorisation Aid" src="https://codepen.io/kwabs22/embed/preview/GRXKQgj?default-tab=result&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
 
 
 
 
 
231
  See the Pen <a href="https://codepen.io/kwabs22/pen/GRXKQgj">
232
  Memorisation Aid</a> by kwabs22 (<a href="https://codepen.io/kwabs22">@kwabs22</a>)
233
  on <a href="https://codepen.io">CodePen</a>.
 
5
  from nltk.corpus import wordnet
6
  import wikipedia
7
  import re
8
+ import time
9
+ import random
10
 
11
  nltk.download('maxent_ne_chunker') #Chunker
12
  nltk.download('stopwords') #Stop Words List (Mainly Roman Languages)
 
211
  def TTSforListeningPractice(text):
212
  return "not finished"
213
 
214
+ def group_words(inlist):
215
+ inlisttoks = inlist.split(" ")
216
+ inlistset = set(inlisttoks)
217
+
218
+ word_groups = []
219
+ current_group = []
220
+
221
+ for word in inlisttoks:
222
+ current_group.append(word)
223
+ if len(current_group) == 10:
224
+ word_groups.append(current_group)
225
+ current_group = []
226
+ if current_group:
227
+ word_groups.append(current_group)
228
+
229
+ current_group_index = 0
230
+ current_group_time = 0
231
+
232
+ while True:
233
+ if current_group_time == 60:
234
+ current_group_index = (current_group_index + 1) % len(word_groups)
235
+ current_group_time = 0
236
+ else:
237
+ if current_group_time % 10 == 0:
238
+ random.shuffle(word_groups[current_group_index])
239
+ current_group_time += 10
240
+
241
+ yield " ".join(word_groups[current_group_index])
242
+ time.sleep(10)
243
+
244
  with gr.Blocks() as lliface:
245
  with gr.Tab("Welcome "):
246
  gr.HTML("""<h1> Spaces Test - Still Undercontruction </h1> <p> You only learn when you convert things you dont know to known --> Normally Repetition is the only reliable method for everybody </p>
 
259
  gr.Interface(fn=keep_nouns_verbs, inputs=["text"], outputs="text", title="Noun and Verbs only (Plus punctuation)")
260
  with gr.Tab("Timing Practice - Repitition"):
261
  gr.HTML("<p>Run from it, Dread it, Repitition is inevitable - Thanos</p> <p>Next Milestone is Turning this interface handsfree</p>")
262
+ with gr.Tab("Gradio Version"):
263
+ input_text = gr.inputs.Textbox(lines=2, label="Enter a list of words")
264
+ output_text = gr.outputs.Textbox(label="Grouped words")
265
+ gr.Interface(fn=group_words, inputs=input_text, outputs=output_text, title="Word Grouping and Rotation", description="Group a list of words into sets of 10 and rotate them every 60 seconds.").queue()
266
+ with gr.Tab("HTML Version"):
267
+ gr.HTML("""<iframe height="1200" style="width: 100%;" scrolling="no" title="Memorisation Aid" src="https://codepen.io/kwabs22/embed/preview/GRXKQgj?default-tab=result&editable=true" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true">
268
  See the Pen <a href="https://codepen.io/kwabs22/pen/GRXKQgj">
269
  Memorisation Aid</a> by kwabs22 (<a href="https://codepen.io/kwabs22">@kwabs22</a>)
270
  on <a href="https://codepen.io">CodePen</a>.