-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (31 loc) · 1.02 KB
/
main.py
File metadata and controls
38 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
This is the main file of the project.
"""
from fastapi import FastAPI
from fastapi.responses import ORJSONResponse
from app.models.word import Word
from app.general.utils import upload_data, query_numeric_words, query_string_words
app = FastAPI(default_response_class=ORJSONResponse)
@app.post("/{words_limit}")
def root(word_params: Word, words_limit: int):
"""
This is the root function of the project.
Parameters
----------
word_params : NumericWord
A Word object containing the parameters of the query
words_limit : int
The number of words to be returned
Returns
-------
list
A list of the query words
"""
df = upload_data("Items.csv")
if any([word_params.age_of_aquisition, word_params.n_phon, word_params.n_syll]):
words = query_numeric_words(df, word_params, words_limit)
elif any([word_params.start_with, word_params.sound_like]):
words = query_string_words(df, word_params, words_limit)
else:
words = []
return words