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

Autocomplete implementation #15

Merged
merged 21 commits into from
May 21, 2024
Merged

Autocomplete implementation #15

merged 21 commits into from
May 21, 2024

Conversation

mehmetcanay
Copy link
Member

Implemented Fuzzy partial string matching for autocomplete, still in search of a library dedicated to the autocomplete.
Added HTTPException to functions that require user input.
Added descriptions to the API endpoints.
Fixed a bug while returning the cohort rankings as a JSON file.
Updated the README file to explain and give guidelines on the project.

@mehmetcanay mehmetcanay linked an issue May 2, 2024 that may be closed by this pull request
4 tasks
@tiadams tiadams self-requested a review May 2, 2024 09:47
README.md Outdated Show resolved Hide resolved
backend/README.md Outdated Show resolved Hide resolved
backend/api/routes.py Outdated Show resolved Hide resolved
frontend/README.md Outdated Show resolved Hide resolved
Copy link
Member

@tiadams tiadams left a comment

Choose a reason for hiding this comment

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

I did not find any file related to autocompletion - did you maybe forget to commit it?

backend/api/routes.py Outdated Show resolved Hide resolved
@tiadams
Copy link
Member

tiadams commented May 3, 2024

I did not find any file related to autocompletion - did you maybe forget to commit it?

@mehmetcanay

@mehmetcanay
Copy link
Member Author

mehmetcanay commented May 3, 2024

I added fuzzy partial string matching for autocompletion for now. It's at the end of routes.py, and the endpoint is called /autocompletion. I will update this functionality once I find a suitable package.

@mehmetcanay
Copy link
Member Author

I added fuzzy partial string matching for autocompletion for now. It's at the end of routes.py, and the endpoint is called /autocompletion. I will update this functionality once I find a suitable package.

@tiadams

@tiadams tiadams self-requested a review May 17, 2024 12:38
backend/README.md Outdated Show resolved Hide resolved

@app.get("/autocompletion", tags=["autocompletion"])
def autocomplete(text: str):
"""
Copy link
Member

Choose a reason for hiding this comment

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

Just tested this with the prompt "Dia" for the /autocomplete Endpoint. I get:

[
  "Diagnosis",
  "American Indian/Alaskan Native",
  "Diabetes",
  "MoCA - Digit Span Test (Forward)",
  "MoCA - Delayed Recall (Daisy)",
  "MoCA - Orientation (Date)",
  "MoCA - Orientation (Day)",
  "IDEA - Day of Week",
  "MDS-UPDRS - Daytime Sleepiness",
  "RBDSQ - Sleep Is Disturbed"
]

This should only return ["Diagnosis", "Diabetes"]. Please adapt this and write a test case for this input.

Copy link
Member

Choose a reason for hiding this comment

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

if the query is "dia" autocomplete should only return terms that start with dia.

And even if American InDIAn/Alaskan Native contains the term, this should definitely be below Diabetes in terms of similarity.

Copy link
Member

Choose a reason for hiding this comment

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

We should probably not use fuzzy matching in autocompletion at all, maybe just macth it with a string based regex instead

Copy link
Member

Choose a reason for hiding this comment

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

For the Query "Di" we will get:

[
  "Diagnosis",
  "MoCA - Digit Span Test (Forward)",
  "MoCA - Digit Span Test (Backward)",
  "FAQ - Pay Attention, Understand, Discuss",
  "Consortium to Establish a Registry for Alzheimer's Disease",
  "ESS - Sitting and Reading",
  "Modified Schwab & England Activities of Daily Living",
  "MDS-UPDRS - Lightheadedness on Standing",
  "MDS-UPDRS - Rigidity Neck",
  "MDS-UPDRS - Rigidity Right Upper Extremity"
]

Here "diabetes" would not even get suggested to the user

Copy link
Member

Choose a reason for hiding this comment

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

@tiadams tiadams self-assigned this May 17, 2024
@mehmetcanay
Copy link
Member Author

mehmetcanay commented May 19, 2024

All the tests are passing on my laptop I don't see what is causing the error. I also did not change any of the tests or the functions that is being tested.

@tiadams
Copy link
Member

tiadams commented May 20, 2024

You can check the test outputs here:
https://github.com/SCAI-BIO/PDataViewer/actions/runs/9148252319/job/25150639965?pr=15

Might be issue with your local workspace, maybe un-comitted files?

@mehmetcanay
Copy link
Member Author

mehmetcanay commented May 21, 2024

It was one of the weirdest bugs. For some reason, all of a sudden, github actions started merging files on a reverse alphabetical order whereas VSCode sorts on alphabetical order. Nothing is really affected as the files are merged, but the test case depended on the specific order of merging. Changed the function accordingly to solve it.

@tiadams
Copy link
Member

tiadams commented May 21, 2024

Could you also add a test case for your new auto-complete function? Would make sense to check:

  • Is the order as expected (first words matching the exact prefix, then fuzzy)
  • What happens if you pass a query that does not match any word above the specified threshold? (should return an empty list)
  • Can you manage to break this by adding special characters which have syntactic meaning in a regular expression (e.g. *, ., \ etc.)

@mehmetcanay
Copy link
Member Author

Renamed preprocessing module to functions and moved autocomplete function into the module because I need to specify the folder. For now I did not want user to access it. I can revert these changes if needed.

Copy link
Member

@tiadams tiadams left a comment

Choose a reason for hiding this comment

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

LGTM!



def test_autocomplete_typo():
query = "agy"
Copy link
Member

Choose a reason for hiding this comment

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

great testcase!

@@ -1,6 +1,5 @@
import pandas as pd

from preprocessing.visualization import generate_chords
from functions.visualization import generate_chords

Copy link
Member

Choose a reason for hiding this comment

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

might make sense to eventually move this into a visualization package, fine for now though

@tiadams tiadams merged commit 29b4688 into main May 21, 2024
5 checks passed
@tiadams tiadams deleted the autocomplete-implementation branch May 21, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create README.md
2 participants