Package: fastdetect
fastdetectManual PageNAMEfastdetect - run a lightweight language detection serverSYNOPSISfastdetect bind_addr port model_path [--workers] [--cors]DESCRIPTIONFastDetect is a lightweight language detection server that is capable of recognizing 175 languages using a data model trained on source text from Wikipedia, Tatoeba, and SETimes. It is powered by the Facebook developedfastTextlibrary, and usesBottlewithgunicornto provide a REST-style interface in which to interact with the model.Please seehttps://fasttext.cc/for more information.OPTIONSbind_addrThe IP address or hostname that this server process will bind to.portThe port used by this server process to listen for incoming requests.model_pathThe path to the model file. This file can be found athttps://fasttext.cc/docs/en/language-identification.html--workers=COUNTThe number of worker processes that will be used to serve responses. The
default value if omitted is 1.--cors=DOMAINIf given, CORS requests will be accepted from the given domain. AnAccess-Control-Allow-Originheader 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.ENDPOINTSXYZ /Unconditionally serves 200 with an empty response body. Used primarily for
performing health checks on the server.XYZmay be any canonical HTTP request
method.OPTIONS /detectOnePreflighting forPOST /detectOneendpoint.POST /detectOneDetect the language of a single utterance. The request body should
comport with theapplication/jsoncontent-type, and should contain
a JSON object with a MANDATORY top-leveldataproperty containing the
utterance to be detected. An optionalpredictionsproperty containing
an integer value may be given to alter the number of predictions that
are returned (the default value is 1).OPTIONS /detectManyPreflighting for 'POST /detectMany' endpoint.POST /detectManyDetect the language of an array of utterances. The request body should
comport with theapplication/jsoncontent-type, and should contain
a JSON object with a MANDATORY top-leveldataproperty containing the
array of utterances to be detected. An optionalpredictionsproperty
containing an integer value may be given to alter the number of
predictions that are returned (the default value is 1).OUTPUT200Successful responses are of the content-typeapplication/json, and
contain a JSON object containing a top-level property nameddata. This
property either contains an object with a string propertyutterancecontaining the original utterance and an object property
containing thedetectedLanguageandconfidencefor each prediction,
or an array of said objects.400Malformed requests are given responses of the content-typeapplication/jsonwhich contain two properties:errorCode, which
provides a code for the given error, anderrorDescritpion, which is
a detailed explaination of the error. Note that unsupported CORS
requests fall under this category.EXIT CODES0This exit code is used if no errors ocurred during execution.1This exit code is used if the given data model file cannot be found.
Also raised if any unexpected runtime exceptions are raised.2This exit code is used if the given argument vector was malformed.AUTHORWritten by Kristoffer A. Wright (kris.al.wright@gmail.com)COPYRIGHTCopyright (C) 2022 Kristoffer A. WrightThis software is protected under the MIT license.
Please see the LICENSE file for more information.Sample JSON Requests and ResponsesSamplePOST /detectOneRequest Body{"data":"The man in black fled across the desert, and the gunslinger followed."}SamplePOST /detectOneResponse Body{"data":{"utterance":"The man in black fled across the desert, and the gunslinger followed.","results":[{"detectedLanguage":"en","confidence":0.9147520065307617},{"detectedLanguage":"it","confidence":0.01209554634988308},{"detectedLanguage":"pt","confidence":0.009296770207583904}]}}SamplePOST /detectManyRequest Body{"data":["The man in black fled across the desert, and the gunslinger followed.","Hola. Como estas?","Muž v černém uprchl přes poušť a pistolník ho následoval.","검은 옷을 입은 남자는 사막을 가로질러 도망쳤고 총잡이는 그 뒤를 따랐다."]}SamplePOST /detectManyResponse Body{"data":[{"utterance":"The man in black fled across the desert, and the gunslinger followed.","results":[{"detectedLanguage":"en","confidence":0.9147520065307617},{"detectedLanguage":"it","confidence":0.01209554634988308},{"detectedLanguage":"pt","confidence":0.009296770207583904}]},{"utterance":"Hola. Como estas?","results":[{"detectedLanguage":"es","confidence":0.7752323746681213},{"detectedLanguage":"pt","confidence":0.20101742446422577},{"detectedLanguage":"gl","confidence":0.015422248281538486}]},{"utterance":"Muž v černém uprchl přes poušť a pistolník ho následoval.","results":[{"detectedLanguage":"cs","confidence":0.9968787431716919},{"detectedLanguage":"en","confidence":0.0011031883768737316},{"detectedLanguage":"ro","confidence":0.0007685713935643435}]},{"utterance":"검은 옷을 입은 남자는 사막을 가로질러 도망쳤고 총잡이는 그 뒤를 따랐다.","results":[{"detectedLanguage":"ko","confidence":1.0000699758529663},{"detectedLanguage":"tr","confidence":1.0000403563026339e-05},{"detectedLanguage":"en","confidence":1.0000098882301245e-05}]}]}