yashm commited on
Commit
a8d46eb
·
verified ·
1 Parent(s): 93cd9d8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +218 -0
app.py ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import spacy
3
+
4
+ # Load the spaCy English model
5
+ nlp = spacy.load("en_core_web_sm")
6
+
7
+ # Function to analyze and explain a sentence
8
+ def analyze_sentence(sentence):
9
+ doc = nlp(sentence)
10
+ explanations = []
11
+ for token in doc:
12
+ explanations.append((token.text, token.lemma_, token.pos_, spacy.explain(token.tag_)))
13
+ return explanations
14
+
15
+ # Streamlit app
16
+ st.title("Biology English Grammar Helper")
17
+ st.write("This tool helps biology students learn English grammar tenses with relevant examples.")
18
+
19
+ # Tenses and explanations
20
+ tenses = {
21
+ 'Present Simple': {
22
+ 'structure': 'Subject + base form of the verb (third person singular adds "s")',
23
+ 'use': 'Used for repeated actions, general facts, and habits.',
24
+ 'examples': [
25
+ ("The cell divides to reproduce.", "Describing a general biological process."),
26
+ ("Water boils at 100 degrees Celsius.", "Stating a scientific fact."),
27
+ ("A caterpillar becomes a butterfly.", "Describing a natural transformation process."),
28
+ ("Genes determine eye color.", "Explaining a genetic fact."),
29
+ ("Plants produce oxygen through photosynthesis.", "Describing a photosynthesis process."),
30
+ ("Enzymes speed up chemical reactions.", "Explaining the role of enzymes in biology."),
31
+ ("The Earth revolves around the Sun.", "Describing an astronomical fact relevant to biology."),
32
+ ("Herbivores eat plants.", "Stating a fact about animal diet."),
33
+ ("Bacteria reproduce quickly in favorable conditions.", "Describing bacteria reproduction."),
34
+ ("The heart pumps blood throughout the body.", "Explaining a biological function."),
35
+ ("Insects play vital roles in ecosystems.", "General statement about biology."),
36
+ ("DNA carries genetic information.", "Fundamental fact of genetics.")
37
+ ]
38
+ },
39
+ 'Present Continuous': {
40
+ 'structure': 'Subject + am/is/are + verb-ing',
41
+ 'use': 'Used for actions happening right now or currently ongoing actions.',
42
+ 'examples': [
43
+ ("The scientist is observing the cell under a microscope.", "Describing an action happening currently in a lab."),
44
+ ("The flowers are blooming this season.", "Describing a seasonal process happening now."),
45
+ ("We are studying the effects of climate change on migration patterns.", "Explaining current research."),
46
+ ("Bacteria are multiplying under the right conditions.", "Describing a process occurring at the moment."),
47
+ ("The planet is warming due to global warming.", "Discussing a current global issue."),
48
+ ("The researcher is analyzing the DNA sample.", "Current activity in a lab."),
49
+ ("Bees are pollinating the plants.", "Active process in nature."),
50
+ ("Scientists are debating the new theory.", "Current academic discussion."),
51
+ ("The doctor is examining the patient now.", "Ongoing medical examination."),
52
+ ("Students are learning about cellular processes.", "Current educational activity.")
53
+ ]
54
+ },
55
+ 'Past Simple': {
56
+ 'structure': 'Subject + past form of the verb',
57
+ 'use': 'Used for actions completed in the past at a specific time.',
58
+ 'examples': [
59
+ ("The scientist discovered a new species last year.", "Describing a completed action in the past."),
60
+ ("The dinosaurs roamed the earth millions of years ago.", "Stating a historical fact."),
61
+ ("Mendel conducted genetic experiments in the 19th century.", "Discussing historical experiments."),
62
+ ("The patient recovered fully after the treatment.", "Describing a completed health recovery."),
63
+ ("Researchers isolated the gene in 2001.", "Pointing out the completion of research at a specific time."),
64
+ ("The lab technician tested the blood sample yesterday.", "Describing an action done in the recent past."),
65
+ ("Marie Curie discovered radium in 1898.", "Highlighting a significant historical discovery."),
66
+ ("The medical team successfully performed the surgery last week.", "Stating a completed medical procedure."),
67
+ ("Scientists identified the virus in the early 20th century.", "Indicating when a scientific discovery was made."),
68
+ ("The biologist recorded the data before the deadline.", "Stating a completed action with a time reference."),
69
+ ]
70
+ },
71
+ 'Past Continuous': {
72
+ 'structure': 'Subject + was/were + verb-ing',
73
+ 'use': 'Used for actions that were in progress at a specific time in the past.',
74
+ 'examples': [
75
+ ("The scientists were researching new vaccines when the outbreak occurred.", "Describing an ongoing action interrupted by another action."),
76
+ ("The cells were dividing rapidly under the microscope.", "Describing an ongoing process observed in the past."),
77
+ ("The biologist was observing the organisms all night.", "Detailing a prolonged action in the past."),
78
+ ("Researchers were experimenting with the new compound when the accident happened.", "Showing an action interrupted by another."),
79
+ ("The students were studying when the fire alarm rang.", "An action occurring at a specific past time interrupted by another event."),
80
+ ("The flowers were blooming throughout the spring season.", "Describing an action that was happening over a period in the past."),
81
+ ("The nurse was checking the patient's vital signs every hour.", "Indicating a continuous action at a certain time."),
82
+ ("The deer were grazing in the field at sunset.", "Setting a scene of an ongoing action in the past."),
83
+ ("Scientists were debating the new theory for hours.", "Showing a prolonged discussion in the past."),
84
+ ("The professor was explaining the concept when the power went out.", "An ongoing action interrupted by another event."),
85
+ ]
86
+ },
87
+ 'Future Simple': {
88
+ 'structure': 'Subject + will + base form of the verb',
89
+ 'use': 'Used for decisions, promises, predictions, and offers about the future.',
90
+ 'examples': [
91
+ ("The biotech company will release the new drug next year.", "Making a prediction about a future event."),
92
+ ("I will study the effects of this gene.", "Expressing a future decision."),
93
+ ("The conference will happen in Geneva next month.", "Announcing a future event."),
94
+ ("Scientists will discover more about this phenomenon.", "Predicting future scientific discoveries."),
95
+ ("We will review the test results tomorrow.", "Stating a future action related to data analysis."),
96
+ ("The government will fund the new research project.", "Predicting future financial support for research."),
97
+ ("The medical trial will begin next week.", "Announcing the start of a new medical trial."),
98
+ ("We will publish our findings in the upcoming issue.", "Stating a future action related to academic publication."),
99
+ ("The student will present her thesis tomorrow.", "Announcing a future academic presentation."),
100
+ ("They will test the hypothesis in the next phase of the experiment.", "Predicting the next step in research."),
101
+ ]
102
+ },
103
+ 'Present Perfect': {
104
+ 'structure': 'Subject + has/have + past participle of the verb',
105
+ 'use': 'Used for actions or situations that started in the past and continue into the present, or actions completed at an unspecified time.',
106
+ 'examples': [
107
+ ("Researchers have discovered several vaccines for the virus.", "Describing actions completed at an unspecified time."),
108
+ ("The species has evolved significantly over the last million years.", "A process that started in the past and continues."),
109
+ ("Scientists have found evidence supporting the new theory.", "Recent discoveries influencing current beliefs."),
110
+ ("The team has completed the initial phase of the research.", "Completion of part of a longer-term project."),
111
+ ("Biologists have observed a decrease in biodiversity.", "An ongoing observation starting in the past."),
112
+ ("We have developed a new method for DNA sequencing.", "Announcing the completion of a development process."),
113
+ ("Researchers have been investigating the cause of the disease for years.", "An ongoing research effort."),
114
+ ("The medicine has improved the quality of life for many patients.", "A continuing impact from a past action."),
115
+ ("Scientists have debated this theory for decades.", "A debate that started in the past and continues."),
116
+ ("The population has increased significantly due to conservation efforts.", "A result of ongoing efforts."),
117
+ ]
118
+ },
119
+ 'Past Perfect': {
120
+ 'structure': 'Subject + had + past participle of the verb',
121
+ 'use': 'Used for actions that were completed before another action in the past.',
122
+ 'examples': [
123
+ ("By the time the paper was published, the scientist had already started a new project.", "Describing an action completed before another past action."),
124
+ ("The researchers had finished the experiments before the deadline.", "Completion of one action before another."),
125
+ ("She had studied biology before she moved to physics.", "Stating a completed action before another in the past."),
126
+ ("The species had become extinct before the scientific community noticed.", "An event occurring prior to another event."),
127
+ ("They had synthesized the compound before the reaction occurred.", "Completion of an action before another event."),
128
+ ("The doctor had seen the symptoms before the diagnosis was confirmed.", "Observing symptoms before making a diagnosis."),
129
+ ("We had submitted our article before the conference was announced.", "Submitting work before another event."),
130
+ ("The professor had left the university before the semester ended.", "Leaving an institution before a specific time."),
131
+ ("The scientist had received the award before the discovery was questioned.", "Receiving recognition before future controversy."),
132
+ ("The medication had been approved before new side effects were found.", "Approval of medication before new findings emerged."),
133
+ ]
134
+ },
135
+ 'Future Perfect': {
136
+ 'structure': 'Subject + will have + past participle of the verb',
137
+ 'use': 'Used for actions that will be completed before a specific time in the future.',
138
+ 'examples': [
139
+ ("By next year, the biologist will have completed the research.", "Completing future work before a set time."),
140
+ ("The students will have graduated by the time the new semester starts.", "Completing an education phase before a future date."),
141
+ ("We will have finished the experiment before the conference.", "Finishing work before a forthcoming event."),
142
+ ("The technician will have analyzed all samples by tomorrow morning.", "Completing tasks before a future moment."),
143
+ ("The paper will have been published by the time the meeting occurs.", "Publishing work before a scheduled event."),
144
+ ("They will have mapped the entire genome by next month.", "Completing a project before a specified time."),
145
+ ("The new species will have been classified before the year ends.", "Classifying new findings within a timeframe."),
146
+ ("We will have reviewed all the literature on this topic by next week.", "Completing research before a future date."),
147
+ ("The project will have reached its fifth year by the end of this decade.", "Reaching a milestone before a future date."),
148
+ ("The experiment will have run for 24 hours by tomorrow.", "Completing a time-bound experiment."),
149
+ ]
150
+ },
151
+ 'Present Perfect Continuous': {
152
+ 'structure': 'Subject + has/have been + verb-ing',
153
+ 'use': 'Used for actions that began in the past and continue to the present, especially with how long the action has been happening.',
154
+ 'examples': [
155
+ ("Scientists have been studying global warming for decades.", "An ongoing study starting in the past."),
156
+ ("We have been researching the effects of this drug for over a year.", "Continuous research effort."),
157
+ ("The biologist has been observing the species since last month.", "Ongoing observation starting in the past."),
158
+ ("Researchers have been debating this issue for many years.", "A continuous debate that started in the past."),
159
+ ("The team has been working on the project since 2010.", "Long-term project engagement."),
160
+ ("I have been teaching biology at the university for five years.", "Long-term teaching engagement."),
161
+ ("They have been trying to find a cure for this disease for a long time.", "Ongoing medical research."),
162
+ ("We have been developing new methodologies for data analysis.", "Continuous development of methods."),
163
+ ("The scientist has been contributing to this field for decades.", "Long-term contributions to a field."),
164
+ ("She has been studying the migration patterns of these birds for several seasons.", "Ongoing study across different times."),
165
+ ]
166
+ },
167
+ 'Past Perfect Continuous': {
168
+ 'structure': 'Subject + had been + verb-ing',
169
+ 'use': 'Used for actions that were happening before another action or time in the past.',
170
+ 'examples': [
171
+ ("The researcher had been working on the project for five years before it was terminated.", "Ongoing work that ended."),
172
+ ("They had been studying the phenomenon for several months before the breakthrough.", "Continuous study before a significant discovery."),
173
+ ("He had been teaching at the university for a decade before he retired.", "Long-term teaching before retirement."),
174
+ ("The scientists had been researching the area before the funding was cut.", "Ongoing research that was stopped."),
175
+ ("We had been observing the species for years before the habitat was destroyed.", "Long-term observation ended by an event."),
176
+ ("The team had been conducting experiments before the lab was closed.", "Ongoing experiments halted by a closure."),
177
+ ("She had been collecting data before the new regulations were implemented.", "Data collection stopped by new rules."),
178
+ ("They had been tracking the storm's progress before it changed course.", "Monitoring an event before a change."),
179
+ ("The doctor had been treating the patient for weeks before the improvement was noted.", "Ongoing treatment before noticing changes."),
180
+ ("Researchers had been debating the theory before new evidence emerged.", "Ongoing debates halted by new findings."),
181
+ ]
182
+ },
183
+ 'Future Perfect Continuous': {
184
+ 'structure': 'Subject + will have been + verb-ing',
185
+ 'use': 'Used for actions that will continue up until a point in the future.',
186
+ 'examples': [
187
+ ("By next month, the student will have been studying biology for four years.", "Studying up to a future point."),
188
+ ("The scientists will have been researching the vaccine for over a decade by the time it is released.", "Researching until a future moment."),
189
+ ("We will have been monitoring the ecosystem for a full year by next spring.", "Monitoring until a certain future time."),
190
+ ("She will have been working in the field of marine biology for twenty years by 2025.", "Working until a specified future date."),
191
+ ("They will have been compiling the report for three months by the deadline.", "Compiling a report up to a future deadline."),
192
+ ("The professor will have been teaching at the university for a quarter of a century by next year.", "Teaching until a future time."),
193
+ ("Researchers will have been analyzing the data for weeks by the time the conference arrives.", "Analyzing data until a certain event."),
194
+ ("The conservationists will have been protecting the endangered species for several years by the time the project ends.", "Protecting a species up until a project's conclusion."),
195
+ ("The students will have been preparing their thesis projects for several months by the time of submission.", "Preparing academic work until submission."),
196
+ ("The team will have been operating under the new guidelines for two years by the time the review is conducted.", "Operating within guidelines until a review."),
197
+ ]
198
+ },
199
+ }
200
+
201
+ # Select a tense
202
+ tense_selected = st.selectbox("Choose a tense to learn:", list(tenses.keys()))
203
+
204
+ # Display selected tense information
205
+ if tense_selected:
206
+ st.subheader(f"{tense_selected} Tense")
207
+ tense_info = tenses[tense_selected]
208
+ st.write(f"**Structure:** {tense_info['structure']}")
209
+ st.write(f"**Use:** {tense_info['use']}")
210
+ st.markdown("**Examples:**")
211
+ for example, explanation in tense_info['examples']:
212
+ st.write(f"- **{example}**: {explanation}")
213
+ if st.button(f'Analyze "{example}"', key=example): # Unique key for each button
214
+ with st.spinner('Analyzing...'):
215
+ explanations = analyze_sentence(example)
216
+ st.write("Analysis (Word, Base Form, Part of Speech, Explanation):")
217
+ for exp in explanations:
218
+ st.write(exp)