Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import spacy
|
|
3 |
import gradio as gr
|
4 |
import nltk
|
5 |
from nltk.corpus import wordnet
|
|
|
6 |
|
7 |
nltk.download('maxent_ne_chunker') #Chunker
|
8 |
nltk.download('stopwords') #Stop Words List (Mainly Roman Languages)
|
@@ -120,16 +121,28 @@ def SepHypandSynExpansion(text):
|
|
120 |
synonyms += synset.lemma_names()
|
121 |
hypernyms += [hypernym.name() for hypernym in synset.hypernyms()]
|
122 |
if not synonyms and not hypernyms:
|
123 |
-
NoHits += f"{token} | "
|
|
|
124 |
else:
|
125 |
FinalOutput += "\n" f"{token}: hypernyms={hypernyms}, synonyms={synonyms}"
|
126 |
return NoHits, FinalOutput
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
with gr.Blocks() as lliface:
|
129 |
-
with gr.Tab("Welcome"):
|
130 |
-
gr.HTML("<h1> Spaces Test - Still Undercontruction </h1> <p> Knowledge is a Language </p>
|
|
|
|
|
131 |
with gr.Tab("Transcribe - RASMUS Whisper"):
|
132 |
-
gr.HTML("""<a href="https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles">https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles</a>""")
|
133 |
gr.Interface.load("spaces/RASMUS/Whisper-youtube-crosslingual-subtitles", title="Subtitles")
|
134 |
with gr.Tab("Chunks"):
|
135 |
gr.Interface(fn=FrontRevSentChunk, inputs=[ChunkModeDrop, "checkbox", "text", langdest], outputs="text")
|
@@ -137,6 +150,7 @@ with gr.Blocks() as lliface:
|
|
137 |
with gr.Tab("Unique words, Hypernyms and synonyms"):
|
138 |
gr.Interface(fn=unique_word_count, inputs="text", outputs="text", title="Wordcounter")
|
139 |
gr.Interface(fn=SepHypandSynExpansion, inputs="text", outputs=["text", "text"], title="Word suggestions")
|
|
|
140 |
with gr.Tab("Timing Practice"):
|
141 |
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">
|
142 |
See the Pen <a href="https://codepen.io/kwabs22/pen/GRXKQgj">
|
|
|
3 |
import gradio as gr
|
4 |
import nltk
|
5 |
from nltk.corpus import wordnet
|
6 |
+
import wikipedia
|
7 |
|
8 |
nltk.download('maxent_ne_chunker') #Chunker
|
9 |
nltk.download('stopwords') #Stop Words List (Mainly Roman Languages)
|
|
|
121 |
synonyms += synset.lemma_names()
|
122 |
hypernyms += [hypernym.name() for hypernym in synset.hypernyms()]
|
123 |
if not synonyms and not hypernyms:
|
124 |
+
NoHits += token + " " # f"{token} | "
|
125 |
+
NoHits = set(NoHits)
|
126 |
else:
|
127 |
FinalOutput += "\n" f"{token}: hypernyms={hypernyms}, synonyms={synonyms}"
|
128 |
return NoHits, FinalOutput
|
129 |
|
130 |
+
|
131 |
+
def WikiSearch(term):
|
132 |
+
termtoks = term.split(" ")
|
133 |
+
|
134 |
+
for item in termtoks:
|
135 |
+
# Search for the term on Wikipedia and get the first result
|
136 |
+
result = wikipedia.search(item, results=20)
|
137 |
+
return result
|
138 |
+
|
139 |
with gr.Blocks() as lliface:
|
140 |
+
with gr.Tab("Welcome "):
|
141 |
+
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> <p> Knowledge is a Language </p> <p>LingQ is good option for per word state management</p> <p> Arrows app json creator for easy knowledge graphing and spacy POS graph? </p> <p> https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles<br>, https://huggingface.co/spaces/vumichien/whisper-speaker-diarization<br> Maybe duplicate these, private them and then load into spaces? --> Whisper space for youtube, Clip Interrogator, load here and all my random functions esp. text to HTML </p>")
|
142 |
+
with gr.Tab("LingQ Addons ideas"):
|
143 |
+
gr.HTML("Extra functions needed - Persitent Sentence translation, UNWFWO, POS tagging and Word Count per user of words in their account")
|
144 |
with gr.Tab("Transcribe - RASMUS Whisper"):
|
145 |
+
gr.HTML("""<p>If this tab doesnt work use the link below ⬇️</p> <a href="https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles">https://huggingface.co/spaces/RASMUS/Whisper-youtube-crosslingual-subtitles</a>""")
|
146 |
gr.Interface.load("spaces/RASMUS/Whisper-youtube-crosslingual-subtitles", title="Subtitles")
|
147 |
with gr.Tab("Chunks"):
|
148 |
gr.Interface(fn=FrontRevSentChunk, inputs=[ChunkModeDrop, "checkbox", "text", langdest], outputs="text")
|
|
|
150 |
with gr.Tab("Unique words, Hypernyms and synonyms"):
|
151 |
gr.Interface(fn=unique_word_count, inputs="text", outputs="text", title="Wordcounter")
|
152 |
gr.Interface(fn=SepHypandSynExpansion, inputs="text", outputs=["text", "text"], title="Word suggestions")
|
153 |
+
gr.Interface(fn=WikiSearch, inputs="text", outputs="text", title="Unique word suggestions(wiki articles)")
|
154 |
with gr.Tab("Timing Practice"):
|
155 |
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">
|
156 |
See the Pen <a href="https://codepen.io/kwabs22/pen/GRXKQgj">
|