Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
569a828
Write draft code
Apr 7, 2021
ff5bf89
Turn grammar analyzer to dictionary
Apr 7, 2021
267fda2
Fix syntax
Apr 7, 2021
4551f66
Fix syntax
Apr 7, 2021
2852767
Fix syntax
Apr 7, 2021
0b20760
disable missingdocstring pylint
Apr 7, 2021
04f2d68
Disable missing docstring
Apr 7, 2021
a72afbc
Update todo list
Apr 7, 2021
5dc6595
Update Piplock file and reformat source code
Apr 14, 2021
7582c90
Fixing source code of grammar_analyzer
Apr 14, 2021
d69ac16
Fixing flake8 error and add comment to src code
Apr 14, 2021
5d0443e
Fixing source code
Apr 14, 2021
a164b88
beginning of the analyzer display code
TheShiny1 Apr 14, 2021
7b8945b
Change grammar error source code according to Product Owner's suggest…
Apr 15, 2021
56d6397
Change grammar error source code according to Product Owner's suggest…
Apr 15, 2021
456953d
Change grammar analyzer source code according to Product Owner's sugg…
Apr 15, 2021
b5f21fe
building of the grammar analyzer display
TheShiny1 Apr 16, 2021
7a5dfec
additional grammar method
Kevin487 Apr 16, 2021
79c88a6
more edits
Kevin487 Apr 16, 2021
3bbfbab
grammar_analyzer edit
Kevin487 Apr 19, 2021
155f99e
Update data structure and fix some displaying code
Apr 19, 2021
ffbb05d
minor changes with the streamlit code and implementation in visualizatio
TheShiny1 Apr 20, 2021
3f2bc5b
Merge branch 'issue#58' of github.com:Allegheny-Ethical-CS/GatorMiner…
TheShiny1 Apr 20, 2021
faa8510
change to code to match summary display
TheShiny1 Apr 20, 2021
7802022
Fix source code and change display code
Apr 21, 2021
cf5b454
Update grammar analyzer source code
Apr 21, 2021
cca35ea
adding student selection for grammar analyzer display
TheShiny1 Apr 21, 2021
a88987e
Debug the grammar analyzer
Apr 21, 2021
4490425
Merge branch 'issue#58' of github.com:Allegheny-Ethical-CS/GatorMiner…
TheShiny1 Apr 21, 2021
17ddf3e
finished the test coding for grammar analyzer
Batmunkh0419 Apr 21, 2021
832c0b1
Fix linting, upload test case, and test another data frame
Apr 21, 2021
e78aefb
Fix linting, upload test case, and test another data frame
Apr 21, 2021
3517a14
Reupload test case
Apr 21, 2021
5db3897
Fix pylint error
Apr 21, 2021
00d5569
Resolving changes requested from TL, program remain tested but not di…
Apr 21, 2021
c58d396
Update pipfile to resolve merge conflict
Apr 21, 2021
46aef18
Merge branch 'master' into issue#58
Mai1902 Apr 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ scipy = "*"
pylint = "*"
importlib-metadata = "*"
atomicwrites = "*"
language_tool_python = "*"


[pipenv]
allow_prereleases = true
106 changes: 69 additions & 37 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions src/grammar_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Compute and return number of grammar error in text"""
import language_tool_python
import re

# Mention the language keyword


def grammar_analyzer(text: str) -> int:
'''A tool to check grammar error and grade it in the reflection'''
tool = language_tool_python.LanguageTool('en-US')

# Variable represent number of grammar errors in the text
err_num = 0

# count for grammar errors
for line in text:
matches = tool.check(line)
err_num = err_num + len(matches)

# Store all alphanumeric characters in the reflection in a list
words = re.sub('[^0-9a-zA-Z]+', ' ', str(text)).lower().split()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not great at regex, although, is this line tokenizing the text?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is expected to replace all non alphanumeric character in the text with white space and then tokenize that text, store under the list call words.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks! That's what I thought! If that's the case, the tokens are already processed and stored in the data frame when markdown documents are being imported. See if you can just reuse them instead of retokenizing from the text.


# Calculate the error percentage of grammar error per number of words
err_percentage = 0
if len(words) != 0:
err_percentage = int(100*err_num/(len(words)))

return err_num, err_percentage
27 changes: 26 additions & 1 deletion streamlit_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import src.summarizer as sz
import src.topic_modeling as tm
import src.visualization as vis
import src.grammar_analyzer as ga


# resources/sample_reflections/lab1, resources/sample_reflections/lab2
Expand All @@ -34,7 +35,6 @@
success_msg = None
debug_mode = False


def main():
"""main streamlit function"""
# Title
Expand All @@ -57,6 +57,7 @@ def main():
"Summary",
"Topic Modeling",
"Interactive",
"Grammar Checker"
],
)
if debug_mode:
Expand All @@ -82,6 +83,9 @@ def main():
elif analysis_mode == "Interactive":
st.title(analysis_mode)
interactive()
elif analysis_mode == "Grammar Checker":
st.title(analysis_mode)
grammar_analyzer()
success_msg.empty()

def landing_src():
Expand Down Expand Up @@ -653,5 +657,26 @@ def interactive():
summaries = sz.summarize_text(input_text)
st.write(summaries)


def grammar_analyzer():
"""page for grammar error checker"""
students = st.multiselect(
label="Select specific students below:",
options=main_df[stu_id].unique(),
)

ga_df = main_df[
(main_df[stu_id].isin(students))
& main_df[assign_id].isin(assignments)
].dropna(axis=1, how="all")

# plot all the subplots of different assignments
for column in main_df.columns[2:]:
ga_df[column] = main_df[column].apply(
lambda x: ga.grammar_analyzer(x)
)
st.write(ga_df)


if __name__ == "__main__":
main()
21 changes: 21 additions & 0 deletions tests/test_grammar_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Test case for grammar analyzer feature"""
import src.grammar_analyzer as ga


def test_grammar_analyzer():
'''Test if grammar analyzer produce correct error with a short input'''
input_text = "This are a pen.\
It is beautifuly."
output = ga.grammar_analyzer(input_text)
expected = 2, 28
assert output == expected


def test_grammar_analyzer2():
'''Test if grammar analyzer produce correct error with a paragraph input'''
input_text = "Python can only interpret names that you have\
spelled correctly. This is because when you declare a variable or a function,\
Python store the value with the exact, name you have declared."
output = ga.grammar_analyzer(input_text)
expected = 4, 12
assert output == expected