@@ -42,6 +42,7 @@ def setup_system():
4242if 'study_text_input' not in st .session_state : st .session_state .study_text_input = ""
4343if 'grammar_text_input' not in st .session_state : st .session_state .grammar_text_input = ""
4444if 'plag_text_input' not in st .session_state : st .session_state .plag_text_input = ""
45+ if 'word_counter_input' not in st .session_state : st .session_state .word_counter_input = ""
4546
4647if 'set_color' not in st .session_state : st .session_state .set_color = "#3b82f6"
4748if 'set_bg' not in st .session_state : st .session_state .set_bg = "#1e293b"
@@ -132,47 +133,37 @@ def trigger_master_reset():
132133 st .image ("z.png" , width = 80 )
133134 st .title ("VERSO PRO" )
134135
135- # Navigation list exactly matching your requirements
136- nav_options = ["🏠 Home" , "📒 Study Assistant" , "✍️ Grammar Checker" , "🛡️ Plagiarism Checker" , "⏱️ Time Tracker" ]
136+ # Updated navigation options to include Word Counter as a full member
137+ nav_options = ["🏠 Home" , "📒 Study Assistant" , "✍️ Grammar Checker" , "🛡️ Plagiarism Checker" , "⏱️ Time Tracker" , "📝 Word Counter" ]
137138
138- # Custom CSS to make the Word Counter Button look like a Nav Item
139- st .markdown ("""
140- <style>
141- div.stButton > button:first-child {
142- border: none;
143- background-color: transparent;
144- color: #FFFFFF;
145- text-align: left;
146- padding: 0px;
147- font-size: 16px;
148- display: flex;
149- align-items: center;
150- }
151- div.stButton > button:first-child:hover {
152- color: #3b82f6;
153- background-color: transparent;
154- }
155- </style>
156- """ , unsafe_allow_html = True )
139+ choice = st .radio ("Navigation" , nav_options + ["⚙️ Settings" ], label_visibility = "collapsed" )
157140
158- # Initial Radio for primary navigation
159- if 'main_nav' not in st .session_state : st .session_state .main_nav = "🏠 Home"
141+ # --- MODULE: WORD COUNTER (NEW SCREEN) ---
142+ if choice == "📝 Word Counter" :
143+ st .title ("Verso Word Metrics" )
160144
161- choice = st .radio ("Menu" , nav_options , label_visibility = "collapsed" )
162-
163- # WORD COUNTER POSITIONED UNDER TIMER AND ABOVE SETTINGS
164- if st .button ("📝 Word Counter" ):
165- all_text = f"{ st .session_state .study_text_input } { st .session_state .grammar_text_input } { st .session_state .plag_text_input } "
166- count = len (re .findall (r'\w+' , all_text ))
167- st .toast (f"Total Session Count: { count } words" )
168- st .sidebar .info (f"Words detected: { count } " )
169-
170- # Settings separated as requested
171- if st .radio ("System" , ["⚙️ Settings" ], label_visibility = "collapsed" , index = None ):
172- choice = "⚙️ Settings"
145+ # Calculated automatic count from other screens
146+ session_text = f"{ st .session_state .study_text_input } { st .session_state .grammar_text_input } { st .session_state .plag_text_input } "
147+ auto_count = len (re .findall (r'\w+' , session_text ))
148+
149+ st .markdown ("### 📊 Live Session Statistics" )
150+ st .markdown (f'<div class="notebook-card" style="border-left-color: #10b981;"><b>Current Session Words Detected:</b> { auto_count } </div>' , unsafe_allow_html = True )
151+
152+ st .write ("---" )
153+ st .markdown ("### 📥 Analyze New Content" )
154+ col_a , col_b = st .columns ([2 , 1 ])
155+ with col_a : st .file_uploader ("Upload Files for Counting" , type = ['pdf' , 'docx' , 'txt' ], key = "word_upload" )
156+ with col_b : st .text_input ("Source URL" , placeholder = "Paste URL to count..." , key = "word_url" )
157+
158+ new_text = st .text_area ("Input specific text to count:" , value = st .session_state .word_counter_input , height = 250 , placeholder = "Paste or type here..." )
159+ st .session_state .word_counter_input = new_text
160+
161+ specific_count = len (re .findall (r'\w+' , new_text ))
162+ st .metric ("Words in Box" , specific_count )
163+ st .metric ("Combined Total" , auto_count + specific_count )
173164
174165# --- MODULE: GRAMMAR CHECKER ---
175- if choice == "✍️ Grammar Checker" :
166+ elif choice == "✍️ Grammar Checker" :
176167 st .markdown ('<h1>Smart Verso Auto-Correct <span class="pro-badge">V5.0</span></h1>' , unsafe_allow_html = True )
177168 text_to_check = st .text_area ("Paste text to improve:" , value = st .session_state .grammar_text_input , height = 250 , placeholder = "Please input the text you want to correct..." , key = "g_input" )
178169 st .session_state .grammar_text_input = text_to_check
@@ -368,7 +359,7 @@ def trigger_master_reset():
368359 if st .button ("Test Tone" ):
369360 components .html ("<script>var a=window.parent.document.getElementById('alarm-sound');if(a){a.load();a.play();}</script>" , height = 0 )
370361
371- st .markdown ("Citations Style" )
362+ st .markdown ("Citation Style" )
372363 st .selectbox ("Citation Style" , ["APA 7th" , "MLA 9th" , "Chicago" , "Harvard" ], label_visibility = "collapsed" )
373364
374365 st .markdown ("Tone Level" )
0 commit comments