File size: 2,172 Bytes
20fe0c2
 
 
c4cfb37
1129ce8
20fe0c2
 
 
463cba4
20fe0c2
 
 
1129ce8
20fe0c2
 
1129ce8
 
 
 
20fe0c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1129ce8
 
 
 
 
 
20fe0c2
 
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
import spacy_streamlit
from spacy.symbols import *
import streamlit as st
import spacy
from annotator import get_annotated_html

DEFAULT_TEXT = """AI has reached superhuman levels in various areas such as playing complex strategic and video games, calculating protein folding, and visual recognition. Are we close to superhuman levels in conversational AI as well?"""

spacy_model = "en_core_web_sm"

replacement_dict= {
"superhuman levels" : "high accuracy",
"conversational AI" : "natural language generation"
}

definitions = {
"natural language generation" : "The subfield of artificial intelligence and computational linguistics that is concerned with the construction of computer systems than can produce understandable texts in English or other human languages from some underlying non-linguistic representation of information (Source: [Wikipedia](https://en.wikipedia.org/wiki/Natural_language_generation))",
"high accuracy" : "Accuracy is how close or far off a given set of measurements (observations or readings) are to their true value. (Source: [Wikipedia](https://en.wikipedia.org/wiki/Accuracy_and_precision)) "
}

st.title("AI Hype Checker")
text = st.text_area("Paste your over-hyped text here:", DEFAULT_TEXT, height=100)
doc = spacy_streamlit.process_text(spacy_model, text)

for chunk in doc.noun_chunks:
    if chunk.text in replacement_dict.keys():
        text= text.replace(chunk.text, replacement_dict[chunk.text])
    else:
        continue

text = st.text_area("Fixed it! See below:", text, height=100)

st.markdown("## Here are the terms that we flagged:")
chunks= [chunk.text for chunk in doc.noun_chunks]
flagged_chunks=[]
for i in range(len(chunks)):
    if chunks[i] in replacement_dict.keys():
        flagged_chunks.append((chunks[i], replacement_dict[chunks[i]]))

flagged_chunks = list(set(flagged_chunks))
for f in flagged_chunks:
    st.markdown(
        get_annotated_html(f),
        unsafe_allow_html=True,
    )

st.markdown("***")

with st.expander("See a definition of these terms"):
    for f in flagged_chunks:
        st.write("**"+f[1]+"**", ": " , definitions[f[1]])


#st.text(f"Analyzed using spaCy model {spacy_model}")