Skip to content

Commit

Permalink
Merge pull request #79 from Knox-AAU/71-docs-and-test-for-switch-lang…
Browse files Browse the repository at this point in the history
…uage-model-depending-on-language-in-data

tests
  • Loading branch information
pbaekgaard authored Nov 29, 2023
2 parents f297cf1 + 3f27c51 commit 928e22c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,17 @@ Here is an example of an output from the endpoint when getting for <span style=
}
]
```



## detectlanguage <sup><span style="color:lightgreen">POST</span></sup>

This endpoint will check the language in the given text.
Send the text in the request body and it will return the language.
The given text has to be longer than 4 characters.
The function will return the lanugage in 2 charaters.

### Example
<span style="color:lightgreen">Request body: </span> The man was walking down the street
<span style="color:lightgreen">Response: </span> en

12 changes: 12 additions & 0 deletions tests/unit/test_Languagedetector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys
from fastapi.testclient import TestClient
import pytest
from main import app
from langdetect import detect

def test_lang_da():
assert detect("hej, jeg bor i et hus som ligger i Aalborg.") == "da"


def test_lang_en():
assert detect("My name is Mike Oxlong. I live in Alabama which is located in the US.") == "en"

0 comments on commit 928e22c

Please sign in to comment.