Skip to content
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

Feature/add spellcheck #34

Merged
merged 9 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.venv
.pytest_cache/
__pycache__
.vscode
.vscode
.env
19 changes: 12 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'''
from flask import Flask, jsonify, request
from models import Experience, Education, Skill
from spell_check import spell_check

app = Flask(__name__)

Expand Down Expand Up @@ -47,10 +48,19 @@ def experience():
if request.method == 'GET':
return jsonify()

if request.method == 'POST':
if request.method == 'POST':
return jsonify({})

return jsonify({})

@app.route('/resume/spell_check', methods=['POST'])
def spell_check():
json_data = request.json
if json_data.get('description') and isinstance(json_data.get('description'), str):
json_data['description'] = spell_check(json_data['description'])
return jsonify({
"before": request.json,
"after": json_data
})

@app.route('/resume/education', methods=['GET', 'POST'])
def education():
Expand All @@ -63,9 +73,6 @@ def education():
if request.method == 'POST':
return jsonify({})

return jsonify({})


@app.route('/resume/skill', methods=['GET', 'POST'])
def skill():
'''
Expand All @@ -76,5 +83,3 @@ def skill():

if request.method == 'POST':
return jsonify({})

return jsonify({})
9 changes: 9 additions & 0 deletions spell_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from autocorrect import Speller

spell = Speller(lang='en')

def spell_check(text):
'''
Spell checks the text
'''
return spell(text)
24 changes: 23 additions & 1 deletion test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''
from app import app


def test_client():
'''
Makes a request and checks the message received is the same
Expand Down Expand Up @@ -72,3 +72,25 @@ def test_skill():

response = app.test_client().get('/resume/skill')
assert response.json[item_id] == example_skill


def test_spell_check():
'''
Test that the spell check endpoint returns a valid response
'''

example_education = {
"course": "Engineering",
"school": "NYU",
"start_date": "October 2022",
"end_date": "August 2024",
"grade": "86%",
"logo": "example-logo.png",
"description": "I was head of the debaite team at university",
"spell_check": True
}

response = app.test_client().post('/resume/education',
json=example_education)

assert response.json['description'] == "I was head of the debate team at university"