A lightweight language detection server
Project description
NAME
fastdetect - run a lightweight language detection server
SYNOPSIS
fastdetect bind_addr port model_path [--workers] [--cors]
DESCRIPTION
Run a lightweight language detection server.
bind_addr
The IP address or hostname that this server process will bind to.
port
The port used by this server process to listen for incoming requests.
model_path
The path to the model file. This file can be found at https://fasttext.cc/docs/en/language-identification.html
--workers=COUNT
The number of worker processes that will be used to serve responses. The default value if omitted is 1.
--cors=DOMAIN
If given, CORS requests will be accepted from the given domain. An
Access-Control-Allow-Origin
header with the given domain will be
included in all responses, unconditionally. Supports the wildcard
character ('*'). Note that if this is omitted, CORS will not be
supported, and all preflight requests will receive a 400 error.
ENDPOINTS
OPTIONS /detectOne
Preflighting for POST /detectOne
endpoint.
POST /detectOne
Detect the language of a single utterance. The request body should
comport with the application/json
content-type, and should contain
a JSON object with a MANDATORY top-level data
property containing the
utterance to be detected. An optional predictions
property containing
an integer value may be given to alter the number of predictions that
are returned (the default value is 1).
OPTIONS /detectMany
Preflighting for 'POST /detectMany' endpoint.
POST /detectMany
Detect the language of an array of utterances. The request body should
comport with the application/json
content-type, and should contain
a JSON object with a MANDATORY top-level data
property containing the
array of utterances to be detected. An optional predictions
property
containing an integer value may be given to alter the number of
predictions that are returned (the default value is 1).
OUTPUT
200
Successful responses are of the content-type application/json
, and
contain a JSON object containing a top-level property named data
. This
property either contains an object with a string property
utterance
containing the original utterance and an object property
containing the detectedLanguage
and confidence
for each prediction,
or an array of said objects.
400
Malformed requests are given responses of the content-type
application/json
which contain two properties: errorCode
, which
provides a code for the given error, and errorDescritpion
, which is
a detailed explaination of the error. Note that unsupported CORS
requests fall under this category.
EXIT CODES
0
This exit code is used if no errors ocurred during execution.
1
This exit code is used if the given data model file cannot be found. Also raised if any unexpected runtime exceptions are raised.
2
This exit code is used if the given argument vector was malformed.
AUTHOR
Written by Kristoffer A. Wright (kris.al.wright@gmail.com)
COPYRIGHT
Copyright (C) 2022 Kristoffer A. Wright
This software is protected under the MIT license. Please see the LICENSE file for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastdetect-1.0.2.tar.gz
.
File metadata
- Download URL: fastdetect-1.0.2.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9f1e02f1cf861a9cfcb57ab1eab506438289a8fa52c521a5dada387362db524 |
|
MD5 | b92ef69c9c0242b62b5238810f286109 |
|
BLAKE2b-256 | b24a35f74a3ee2c0bc32c73d045b06cc04d21f765456c38bbe70505d0657802b |
File details
Details for the file fastdetect-1.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: fastdetect-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee7b9cfbc356b0c0165bad8d5172899c3e5819b12e103c6e3ae58dd8c45f9f61 |
|
MD5 | 52718bbe9eef7ea06b2defff58fec42b |
|
BLAKE2b-256 | ebd5c5aa1d24df1654479440bd9fcb5cad58575594d01177942e7c8115f9cd2b |