ryanrahmadifa commited on
Commit
6811882
·
1 Parent(s): 5b990f6

Fixed error nonetype

Browse files
Files changed (2) hide show
  1. modules/semantic.py +3 -3
  2. page_1.py +1 -1
modules/semantic.py CHANGED
@@ -125,13 +125,13 @@ def tokenize(text):
125
  # Function to apply filtering and plotting based on search input
126
  def generateChartBar(data, search_word, body=False):
127
 
128
- filtered_df = data[data['headline'].str.contains(search_word, case=False) | data['body'].str.contains(search_word, case=False)]
129
 
130
  all_words = []
131
- filtered_df['headline'].apply(lambda x: all_words.extend(tokenize(x)))
132
 
133
  if body:
134
- filtered_df['body'].apply(lambda x: all_words.extend(tokenize(x)))
135
 
136
 
137
  word_counts = Counter(all_words)
 
125
  # Function to apply filtering and plotting based on search input
126
  def generateChartBar(data, search_word, body=False):
127
 
128
+ # filtered_df = data[data['headline'].str.contains(search_word, case=False) | data['body'].str.contains(search_word, case=False)]
129
 
130
  all_words = []
131
+ data['headline'].apply(lambda x: all_words.extend(tokenize(x)))
132
 
133
  if body:
134
+ data['body'].apply(lambda x: all_words.extend(tokenize(x)))
135
 
136
 
137
  word_counts = Counter(all_words)
page_1.py CHANGED
@@ -63,7 +63,7 @@ viz1, viz2 = st.columns(2)
63
 
64
  st.subheader('Top Word Frequency - Bar Chart')
65
 
66
- bar_chart = generateChartBar(data=df_news,search_word='n', body=True)
67
  st.plotly_chart(bar_chart)
68
 
69
 
 
63
 
64
  st.subheader('Top Word Frequency - Bar Chart')
65
 
66
+ bar_chart = generateChartBar(data=df_news,search_word=news_location, body=True)
67
  st.plotly_chart(bar_chart)
68
 
69