-
Notifications
You must be signed in to change notification settings - Fork 8
Issue#58: Adding Grammar Analyzer feature to GatorMiner #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Mai1902
wants to merge
37
commits into
master
Choose a base branch
from
issue#58
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
569a828
Write draft code
ff5bf89
Turn grammar analyzer to dictionary
267fda2
Fix syntax
4551f66
Fix syntax
2852767
Fix syntax
0b20760
disable missingdocstring pylint
04f2d68
Disable missing docstring
a72afbc
Update todo list
5dc6595
Update Piplock file and reformat source code
7582c90
Fixing source code of grammar_analyzer
d69ac16
Fixing flake8 error and add comment to src code
5d0443e
Fixing source code
a164b88
beginning of the analyzer display code
TheShiny1 7b8945b
Change grammar error source code according to Product Owner's suggest…
56d6397
Change grammar error source code according to Product Owner's suggest…
456953d
Change grammar analyzer source code according to Product Owner's sugg…
b5f21fe
building of the grammar analyzer display
TheShiny1 7a5dfec
additional grammar method
Kevin487 79c88a6
more edits
Kevin487 3bbfbab
grammar_analyzer edit
Kevin487 155f99e
Update data structure and fix some displaying code
ffbb05d
minor changes with the streamlit code and implementation in visualizatio
TheShiny1 3f2bc5b
Merge branch 'issue#58' of github.com:Allegheny-Ethical-CS/GatorMiner…
TheShiny1 faa8510
change to code to match summary display
TheShiny1 7802022
Fix source code and change display code
cf5b454
Update grammar analyzer source code
cca35ea
adding student selection for grammar analyzer display
TheShiny1 a88987e
Debug the grammar analyzer
4490425
Merge branch 'issue#58' of github.com:Allegheny-Ethical-CS/GatorMiner…
TheShiny1 17ddf3e
finished the test coding for grammar analyzer
Batmunkh0419 832c0b1
Fix linting, upload test case, and test another data frame
e78aefb
Fix linting, upload test case, and test another data frame
3517a14
Reupload test case
5db3897
Fix pylint error
00d5569
Resolving changes requested from TL, program remain tested but not di…
c58d396
Update pipfile to resolve merge conflict
46aef18
Merge branch 'master' into issue#58
Mai1902 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
|
|
||
| # 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.