Spaces:
Runtime error
Runtime error
feat: add Rawl's source article; implement titlecase and typos
Browse files- app.py +112 -18
- requirements.txt +3 -0
app.py
CHANGED
@@ -1,26 +1,51 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
headline = st.text_input(
|
4 |
-
"
|
5 |
-
help="Type here what you got and we'll fix it then, don't worry.",
|
6 |
)
|
7 |
-
red = '<p style="color:#C6F1D6;">{}</p>' # TODO consider error box and success box
|
8 |
-
green = '<p style="color:#FF8080;">{}</p>'
|
9 |
-
st.markdown(red.format("abcd"), unsafe_allow_html=True)
|
10 |
-
st.markdown(green.format("defg"), unsafe_allow_html=True)
|
11 |
|
12 |
-
# Use columns or expander to organise that
|
|
|
|
|
|
|
13 |
|
14 |
-
st.header("
|
|
|
15 |
st.checkbox("What the story is about?")
|
16 |
-
st.checkbox("Why the story matters
|
17 |
|
18 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
st.checkbox(
|
20 |
"Share the headline with a few writing peers and see what they think the story is about."
|
|
|
21 |
)
|
22 |
|
23 |
-
st.
|
24 |
st.checkbox(
|
25 |
"Be direct.",
|
26 |
help="Your story is among many a reader is browsing. Be straightforward in what it is about.",
|
@@ -42,17 +67,28 @@ st.checkbox(
|
|
42 |
help="You may want to be poetic, clever, or artistic in the title. The challenge with crafting a title this way is that it becomes opaque. It’s also much easier to write a bad title when striving for something poetic or clever than if you’re going for clarity. In most cases, the reader won’t click to find out more because they didn’t understand what the story was about in the first place.",
|
43 |
)
|
44 |
|
45 |
-
st.
|
46 |
st.checkbox("Could the headline be clearer?")
|
47 |
st.checkbox("Is the headline specific enough?")
|
48 |
st.checkbox("Does the tone reflect the voice or point of view of the article?")
|
49 |
st.checkbox("How might the headline convey what is unique about the story?")
|
50 |
st.checkbox("Is the headline clear and honest about what the story offers the reader?")
|
51 |
|
52 |
-
st.
|
53 |
-
st.checkbox("all caps") # implement
|
54 |
-
st.checkbox("all typos") # implement
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
st.checkbox("profanity") # implement?
|
57 |
st.checkbox("exaggeration")
|
58 |
st.checkbox("mystery")
|
@@ -71,7 +107,7 @@ st.checkbox(
|
|
71 |
|
72 |
"In the short term this may help drive traffic, but in the long term it undermines your integrity as a writer."
|
73 |
|
74 |
-
st.
|
75 |
st.checkbox(
|
76 |
"The key to writing a tempting benefit-based headline is to be specific.",
|
77 |
help="“How to Wake Up Smiling: The 9 Decisions That Led To A Life I Love”\n“This 3-Minute Exercise Will Change the Way You Solve Problems”\n“How I Doubled My Writing Income Overnight By Focusing on One Skill”",
|
@@ -93,6 +129,62 @@ st.checkbox(
|
|
93 |
help="“A Behind the Scenes Look at My Writing Schedule That’s Helped Write 5000+ Articles”\n“Steve Jobs Advice Turned This Programmer Into A Billionaire”\n“8 Really Small Things That Tell You a Lot About Someone”",
|
94 |
)
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
st.header("Sources:")
|
97 |
st.markdown(
|
98 |
"""[”How to Write a Headline” by Medium Creators](https://medium.com/creators-hub/how-to-write-a-headline-a72ab3449150)"""
|
@@ -100,7 +192,9 @@ st.markdown(
|
|
100 |
st.markdown(
|
101 |
"""[”5 Majestic Headline Secrets from Medium’s Most Viral Writers” by Nick Waghorn](https://bettermarketing.pub/5-majestic-headline-secrets-from-mediums-most-viral-writers-506753732dc9)"""
|
102 |
)
|
|
|
|
|
|
|
103 |
|
104 |
# TODO https://medium.com/creators-hub/how-to-write-a-compelling-headline-that-isnt-clickbait-7cb816cec438
|
105 |
-
# TODO https://medium.com/creators-hub/23-examples-of-effective-headlines-2e7f753476f1
|
106 |
# some guidelines repeat
|
|
|
1 |
import streamlit as st
|
2 |
+
from titlecase import titlecase
|
3 |
+
from spellchecker import SpellChecker
|
4 |
+
import nltk
|
5 |
+
from nltk.tokenize import word_tokenize
|
6 |
+
import itertools
|
7 |
|
8 |
+
nltk.download("punkt")
|
9 |
+
|
10 |
+
spell = SpellChecker()
|
11 |
+
|
12 |
+
st.title("Medium Headline")
|
13 |
+
st.caption(
|
14 |
+
"The most important Medium Headline writing articles turned into an interactive app."
|
15 |
+
)
|
16 |
+
""
|
17 |
+
""
|
18 |
+
""
|
19 |
+
""
|
20 |
+
|
21 |
+
st.header("Start with typing your headline idea")
|
22 |
headline = st.text_input(
|
23 |
+
"",
|
|
|
24 |
)
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
# TODO Use columns or expander to organise that
|
27 |
+
# TODO try to write a headline with that tool
|
28 |
+
# TODO maybe using markdown's H1-6 will result in better spacing
|
29 |
+
# TODO split to the most important quidelined (answear question, few traits, auto editing features) and expandable/on button click advanced guidelines
|
30 |
|
31 |
+
st.header("Then follow below guidelines")
|
32 |
+
st.subheader("Make sure your headline answers the ultimate questions:")
|
33 |
st.checkbox("What the story is about?")
|
34 |
+
st.checkbox("Why the story matters?")
|
35 |
|
36 |
+
st.subheader("Make sure the headline is:")
|
37 |
+
st.checkbox("clear")
|
38 |
+
st.checkbox("direct")
|
39 |
+
st.checkbox("assertive")
|
40 |
+
st.checkbox("focused on what is most interesting")
|
41 |
+
|
42 |
+
st.subheader("Consider below actions:")
|
43 |
st.checkbox(
|
44 |
"Share the headline with a few writing peers and see what they think the story is about."
|
45 |
+
"When published, look at what people are saying when they share the article."
|
46 |
)
|
47 |
|
48 |
+
st.subheader("Follow below principles:")
|
49 |
st.checkbox(
|
50 |
"Be direct.",
|
51 |
help="Your story is among many a reader is browsing. Be straightforward in what it is about.",
|
|
|
67 |
help="You may want to be poetic, clever, or artistic in the title. The challenge with crafting a title this way is that it becomes opaque. It’s also much easier to write a bad title when striving for something poetic or clever than if you’re going for clarity. In most cases, the reader won’t click to find out more because they didn’t understand what the story was about in the first place.",
|
68 |
)
|
69 |
|
70 |
+
st.subheader("Guiding questions to consider:")
|
71 |
st.checkbox("Could the headline be clearer?")
|
72 |
st.checkbox("Is the headline specific enough?")
|
73 |
st.checkbox("Does the tone reflect the voice or point of view of the article?")
|
74 |
st.checkbox("How might the headline convey what is unique about the story?")
|
75 |
st.checkbox("Is the headline clear and honest about what the story offers the reader?")
|
76 |
|
77 |
+
st.subheader("Avoid:")
|
78 |
+
st.checkbox("all caps") # implement warning?
|
79 |
+
st.checkbox("all typos") # implement separately?
|
80 |
+
if headline:
|
81 |
+
ll = [[word_tokenize(w), " "] for w in headline.split()]
|
82 |
+
tokens = list(itertools.chain(*list(itertools.chain(*ll))))
|
83 |
+
tokens = [
|
84 |
+
spell.correction(t) if spell.unknown([t]) and t != " " else t for t in tokens
|
85 |
+
]
|
86 |
+
headline = "".join(tokens)
|
87 |
+
headline = titlecase(headline)
|
88 |
+
"Especially consider:"
|
89 |
+
st.info(headline)
|
90 |
+
|
91 |
+
st.checkbox("links") # implement warning with regex
|
92 |
st.checkbox("profanity") # implement?
|
93 |
st.checkbox("exaggeration")
|
94 |
st.checkbox("mystery")
|
|
|
107 |
|
108 |
"In the short term this may help drive traffic, but in the long term it undermines your integrity as a writer."
|
109 |
|
110 |
+
st.subheader("Viral tips:")
|
111 |
st.checkbox(
|
112 |
"The key to writing a tempting benefit-based headline is to be specific.",
|
113 |
help="“How to Wake Up Smiling: The 9 Decisions That Led To A Life I Love”\n“This 3-Minute Exercise Will Change the Way You Solve Problems”\n“How I Doubled My Writing Income Overnight By Focusing on One Skill”",
|
|
|
129 |
help="“A Behind the Scenes Look at My Writing Schedule That’s Helped Write 5000+ Articles”\n“Steve Jobs Advice Turned This Programmer Into A Billionaire”\n“8 Really Small Things That Tell You a Lot About Someone”",
|
130 |
)
|
131 |
|
132 |
+
st.subheader("Headline categories for inspiration")
|
133 |
+
st.write("**Analysis**")
|
134 |
+
st.markdown(
|
135 |
+
"""
|
136 |
+
- What Everyone’s Getting Wrong About the Toilet Paper Shortage
|
137 |
+
- This Looks Like a Depression, Not a Recession
|
138 |
+
- Why All the Warby Parker Clones Are Now Imploding
|
139 |
+
- How the Black Death Radically Changed the Course of History
|
140 |
+
"""
|
141 |
+
)
|
142 |
+
|
143 |
+
st.write("**Bold declaration**")
|
144 |
+
st.markdown(
|
145 |
+
"""
|
146 |
+
- The Office Is Dead
|
147 |
+
- The End of the Girlboss Is Here
|
148 |
+
- Gen X Will Not Go Quietly
|
149 |
+
- The Parents Are Not Alright
|
150 |
+
- Meghan Markle Defeated the British Monarchy
|
151 |
+
- You Haven’t Earned the Right to Be a Basic B*tch Just Yet
|
152 |
+
- Your Inability to Do Pullups Is All In Your Head
|
153 |
+
- History Will Look Kindly on Trump, No Matter What
|
154 |
+
"""
|
155 |
+
)
|
156 |
+
|
157 |
+
st.write("**Descriptive teaser**")
|
158 |
+
st.markdown(
|
159 |
+
"""
|
160 |
+
- How a Hot $100 Million Home Design Startup Collapsed Overnight
|
161 |
+
- The Absurd Story Behind China’s Biggest Bank Robbery
|
162 |
+
- The Privileged Have Entered Their Escape Pods
|
163 |
+
- I Had to Leave My Home Because of the KKK
|
164 |
+
"""
|
165 |
+
)
|
166 |
+
|
167 |
+
st.write("**Instruction**")
|
168 |
+
st.markdown(
|
169 |
+
"""
|
170 |
+
- All Your Most Paranoid Transfer of Power Questions, Answered
|
171 |
+
- How to Avoid Going Insane as a Writer
|
172 |
+
- How to Become Popular Without Being Charming, Funny, or Outgoing
|
173 |
+
- 3 Ways to Rescue a Conversation That’s Going Nowhere
|
174 |
+
"""
|
175 |
+
)
|
176 |
+
|
177 |
+
st.write("**Quote**")
|
178 |
+
st.markdown("- Mom, Why Don’t You Have Any Black Friends?")
|
179 |
+
|
180 |
+
st.write("**Coining terms**")
|
181 |
+
st.markdown(
|
182 |
+
"""
|
183 |
+
- When Black Women Go From Office Pet to Office Threat
|
184 |
+
- Nazi Hippies: When the New Age and Far Right Overlap
|
185 |
+
"""
|
186 |
+
)
|
187 |
+
|
188 |
st.header("Sources:")
|
189 |
st.markdown(
|
190 |
"""[”How to Write a Headline” by Medium Creators](https://medium.com/creators-hub/how-to-write-a-headline-a72ab3449150)"""
|
|
|
192 |
st.markdown(
|
193 |
"""[”5 Majestic Headline Secrets from Medium’s Most Viral Writers” by Nick Waghorn](https://bettermarketing.pub/5-majestic-headline-secrets-from-mediums-most-viral-writers-506753732dc9)"""
|
194 |
)
|
195 |
+
st.markdown(
|
196 |
+
"""[”23 Examples of Effective Headlines” by Nadia Rawls](https://medium.com/creators-hub/23-examples-of-effective-headlines-2e7f753476f1)"""
|
197 |
+
)
|
198 |
|
199 |
# TODO https://medium.com/creators-hub/how-to-write-a-compelling-headline-that-isnt-clickbait-7cb816cec438
|
|
|
200 |
# some guidelines repeat
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
titlecase==2.4
|
2 |
+
pyspellchecker==0.7.0
|
3 |
+
nltk==3.7
|