openapi: 3.2.0 info: description: NLP APIs available on InsightEra NLP Platform title: Platform Nlp API termsOfService: http://swagger.io/terms/ contact: name: API Support email: dev@insightera.co.th license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html version: '1.0' servers: - url: https://nlp.insightera.co.th/api tags: - name: nlp paths: /nlp/address-extractor: post: description: 'A service for converting a plain text address to a structural address where each part of the address are extracted and labeled. A complete list of parts which will be extracted are as follow: 1. Name 2. Phone number 3. Tambol 4. Amphoe 5. Province 6. Postcode 7. Probability of an input text being an address (0.0 to 1.0)' tags: - nlp summary: Address extractor parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagAddr' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagAddrInput' description: Address required: true /nlp/cleaning: post: description: 'A service for normalizing texts, especially texts from social media and chat which tend to be informal and purposely misspelled (or slang), into a cleaner version to ease further analysis: * ''keep_alphabet'' If set, tokenization result which contains only one alphabet will be preserved (default: false). * ''keep_rt'' if set, @RT from Twitter will be preserved (default: false). * ''keep_stopwords'' if set, stopwords will be preserved (default: false). * ''keep_url'' if set, urls will be preserved (default: false). * ''keep_emoji'' if set, emoji will be preserved (default: true). * ''normalize'' if set, misspelled words will be auto-corrected or transformed into a cleaner form (default: false). * ''only_vocab'' If set, words that are not in a dictionary will be removed (default: false).' tags: - nlp summary: Text cleaning parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagCleaningResult' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagCleaningInput' description: Input required: true /nlp/clustering: post: description: 'A service for organizing random texts into multiple groups. The service will try grouping them into a number of group defined by a user (k). * engine: machine learning algorithm: k-mean (default), hierarchy * feature_engine: feature extraction method: bag-of-word (default), word-vector * max_k: maximum cluster (optional) * k: number of cluster (optional). If k is not provided, the service will try to find the least k that makes good cluster automatically.' tags: - nlp summary: Text clustering parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagClusteringOutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagClusteringInput' description: Input required: true /nlp/common-phrase: post: description: 'A clustering service specifically customized for chat log. k: a number of cluster (group) to separate texts into.' tags: - nlp summary: Common phrase parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagCommonPhraseOutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagCommonPhraseInput' description: Input required: true /nlp/country: post: description: 'A service for finding a destination country in an address. The service will return the official name of the country and ISO country code. * User can provide additional aliases for each countries using extra_dict option. * By default, the service will only return one country. If multiple is set, it will return all countries found in an input text.' tags: - nlp summary: Country detection parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagCountryResult' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagCountryInput' description: Input required: true /nlp/datetime-parser-new: post: description: 'A service for converting date and time entities in a plain text, e.g. 17 มกราคม 2020, today, tomorrow, 2 hrs ago to a timestamp. A service supports both Thai and English, and supports both absolute time (24 มิถุนายน 2563) and relative time (เมื่อวาน). ' tags: - nlp summary: Datetime parser parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagDucklingNResult' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagDucklingInput' description: Input required: true /nlp/extract-email: post: description: A service for detect emamil(s) in plain text. tags: - nlp summary: Email extractor parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagEmail' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagEmailInput' description: Email required: true /nlp/ner: post: description: A service which locate and classify named entities into pre-defined categories such as name, locaton and time. tags: - nlp summary: Named Entity Recognition parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagNEROutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagNERInput' description: Input required: true /nlp/ocr: post: description: A servie for extracting text from an image such as a printed paper or a photograph which contains texts. tags: - nlp summary: OCR parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagOCROutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: multipart/form-data: schema: type: object properties: image: type: string description: ImagePath format: binary required: - image /nlp/pos: post: description: A service which classify words in a given sentence into a paricular part-of-speech (Noun, Verb, Pronoun) tags: - nlp summary: POS parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagPOSOutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagPOSInput' description: Input required: true /nlp/qa: post: description: A service for answering questions based on a given story. A user must provide both story and questions in single request. tags: - nlp summary: QA (coming soon) parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagQAOutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagQAInput' description: Input required: true /nlp/sentiment-new: post: description: A service for identifying and categorizing opinions expressed in a given text. The result ranges between -1 (negative) and 1 (positive). tags: - nlp summary: Sentiment analysis parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagSentimentNOutput' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagSentimentNInput' description: Input required: true /nlp/similar: post: description: 'A service for finding semantically related words for a given word. Example use cases are recommendation, clustering and word normalization. * ''top'' is a number of expecting words in the result.' tags: - nlp summary: Similar words parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagSimilarNResult' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagSimilarNInput' description: Input required: true /nlp/spell-correction: post: description: A service which auto-correct and recommends correct words for misspelling words in a sentence. tags: - nlp summary: Spell correction parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagSpellResult' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagSpellInput' description: Input required: true /nlp/tokenize: post: description: 'A service for breaking (tokenize) a sentence into a sequence of words. Only support Thai and English. engine: specify tokenization algorithm to be used, available choices are: * longest_match: Simple longest matching * longest_inse: Add some rule-based improvement to ''longest_match'' * longest_tcc: Apply TCC after ''longest_match'' * deep: LSTM with one character context * deep_context_10: LSTM with 10 (front) + 10 (back) characters context * deep_context_dict: Apply dictionary cross-check to ''deep_context_10''' tags: - nlp summary: Thai text tokenization parameters: - description: Token name: token in: query required: true schema: type: string default: 97051ade29a61c860f57dc9443128464 responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/record.SwagTokenizeResult' '400': description: Bad Request content: application/json: schema: type: string '401': description: Unauthorized content: application/json: schema: type: string '408': description: Request Timeout content: application/json: schema: type: string '500': description: Internal Server Error content: application/json: schema: type: string requestBody: content: application/json: schema: type: object $ref: '#/components/schemas/record.SwagTokenizeInput' description: Input required: true components: schemas: record.SwagNEROutput: type: object properties: message: type: object properties: description: type: string ner: type: array items: type: '&{%!s(token.Pos=1066) %!s(*ast.StructType=&{1068 0xc00044fdd0 false})}' status: type: string record.SwagSpellResult: type: object properties: result: type: object properties: spell: description: Description string `json:"description"` type: array items: type: object properties: index: type: array items: type: integer example: - 3 - 7 spell: type: boolean example: false suggestion: type: array items: type: object properties: สนทนา: type: number example: 0.11273138225078583 สนาน: type: number example: 0.11190706491470337 token: type: string example: สนทน text: type: string example: การสนทนนี้น่าสนใใจ มากๆๆๆ +++ record.SwagTokenizeInput: type: object properties: engine: type: string example: deep_context_10 text: type: string example: เรามาตัดคำไทยกันเถอะ record.SwagAddrInput: type: object properties: text: type: string example: นายปุญญพัฒน์ เศรษฐ์สมบูรณ์ 081-234-5678 110/1 อาคาร KX (ใกล้ๆ BTS วงเวียนใหญ่) ชั้น 14 ถ.กรุงธนบุรี แขวงบางลำภูล่าง เขตคลองสาน กรุงเทพมหานคร 10600 จ-ศ 10:00-19:00 record.SwagDucklingInput: type: object properties: text: type: string example: today record.SwagSentimentNOutput: type: object properties: message: type: object properties: description: type: string sentiments: type: array items: type: object properties: score: type: number example: 0.07 text: type: string example: อากาศดีๆจะมีในยามเช้า เหงาาาาสักเท่าไหร่ status: type: string example: ok record.SwagClusteringOutput: type: object properties: result: type: object properties: message: type: object properties: cluster: type: array items: type: integer example: - 0 - 0 - 0 description: type: string example: k-mean model with bag-of-word. Maximum number of clusters is 1, result have 1 cluster. result: type: string example: ok record.SwagEmailInput: type: object properties: texts: type: array items: type: string example: - สอบถามเพิ่มเติมได้ที่ contact@insightera.co.th ครับ record.SwagSimilarNResult: type: object properties: message: type: object properties: desc: type: string example: Used 'skipgram-5' engine. Choose the top 5 similar words. word: type: string example: สวย word-similarity: type: array items: type: object properties: score: type: number example: 0.59 word: type: string example: น่ารัก status: type: string record.SwagPOSInput: type: object properties: texts: type: array items: type: string example: - นายแดงกินข้าวแกง - มดแดงกินมะม่วง record.SwagQAInput: type: object properties: context: type: string example: จังหวัดแค็วม์โปแลนด์ wojewdztwochemskie เป็นหน่วยการปกครองท้องถิ่นของประเทศโปแลนด์ในช่วงปี ค.ศ.1975 - ค.ศ.1998 จังหวัดได้รับการรวมเข้ากับจังหวัดลูบลินมีเมืองหลักคือแค็วม์ใน ปี ค.ศ.1998 มีพื้นที่ประมาณ 3865 ตารางกิโลเมตรและมีประชากร 248800 คน questions: type: array items: type: string example: - จังหวัดแค็วม์ก่อตั้งขึ้นในปีอะไร - แค็วม์มีพื้นที่เท่าไร - แค็วม์มีจำนวนประชากรกี่คน record.SwagDucklingNResult: type: object properties: status: type: string example: ok timestamp: type: integer example: 1577811600 record.SwagEmail: type: object properties: results: type: array items: type: object properties: emails: type: array items: type: object properties: domain_name: type: string example: insightera.co.th email: type: string example: contact@insightera.co.th scope: type: array items: type: integer example: - 22 - 46 username: type: string example: contact text: type: string example: สอบถามเพิ่มเติมได้ที่ contact@insightera.co.th ครับ status: type: string example: ok record.SwagNERInput: type: object properties: texts: type: array items: type: string example: - นายแดงหิวข้าว - ผมเจอนายแดงตอนเช้า record.SwagQAOutput: type: object properties: result: type: object properties: description: type: string question-answer: type: array items: type: string example: - ' ' - ประมาณ 3865 ตารางกิโลเมตร - 248800 คน record.SwagClusteringInput: type: object properties: engine: type: string example: k-mean feature_engine: type: string example: bag-of-word k: type: integer example: 1 max_k: type: integer example: 3 samples: type: array items: type: string example: - foo - bar - bar record.SwagCountryResult: type: object properties: message: type: object properties: country: type: object properties: code: type: string example: US scope: type: array items: type: integer example: - 5 - 10 text: type: string example: สหรัฐอเมริกา original_text: type: string example: ส่งไปนิวยอหน่อยครับ other: type: string example: ส่งไปหน่อยครับ test_scope: type: object properties: country: type: string example: นิวยอ record.SwagCommonPhraseInput: type: object properties: k: type: integer samples: type: array items: type: string record.SwagCleaningInput: type: object properties: text: type: string example: โอ้โหหหหห๊ วันนี้อากาศร้อนมากกกเลยยย 555 record.SwagTokenizeResult: type: object properties: result: type: object properties: description: type: string example: Using 'deep_context_10' engine text: type: string example: เรามาตัดคำไทยกันเถอะ tokens: type: array items: type: string example: - เรา - มา - ตัด - คำ - ไทย - กัน - เถอะ record.SwagCleaningResult: type: object properties: result: type: object properties: message: type: object properties: text: description: Description string `json:"description" example:""` type: string example: โอ้โหหหหห๊ วันนี้อากาศร้อนมากกกเลยยย 555 tokens: type: array items: type: string example: - โอ้โห - อากาศ - ร้อน - เลย - '555' result: type: string example: ok record.SwagPOSOutput: type: object properties: message: type: object properties: description: type: string pos: type: array items: type: '&{%!s(token.Pos=789) %!s(*ast.StructType=&{791 0xc00044f9e0 false})}' status: type: string record.SwagSpellInput: type: object properties: text: type: string example: การสนทนนี้น่าสนใใจ มากๆๆๆ +++ record.SwagOCROutput: type: object properties: result: type: object properties: filename: type: string example: image_with_text.jpg text: type: string example: 'ทดสอบด้วยภาษาไทย การแกะตัวหนังสือจากภาพ ขอบคุณครับ' status: type: string example: ok record.SwagCommonPhraseOutput: type: object properties: result: type: object properties: common-phrase: type: object properties: samples: type: array items: type: '&{%!s(token.Pos=1330) string}' scores: type: array items: type: integer description: type: string record.SwagSentimentNInput: type: object properties: engine: type: string example: deepsent texts: type: array items: type: string example: - อากาศดีๆจะมีในยามเช้า เหงาาาาสักเท่าไหร่ - ไม่ต้องโทรม้าาา เพราะชั่นจะไหมรับสาย - สนใจนะครับ - ชอบๆ สนุกดีดีดีดี - อาหารไม่อร่อยเลยนะ - หงุดหงิดจังเลยโว้ยยยย record.SwagCountryInput: type: object properties: extra_dict: type: array items: type: object properties: alias_english: type: array items: type: string example: - New York alias_thai: type: array items: type: string example: - นิวยอค country_code: type: string example: US multiple: type: boolean example: false text: type: string example: ส่งไปนิวยอหน่อยครับ record.SwagSimilarNInput: type: object properties: engine: type: string example: skipgram-5 top: type: integer example: 5 word: type: string example: สวย record.SwagAddr: type: object properties: message: type: object properties: amphoe: type: object properties: scope: type: array items: type: integer example: - 116 - 126 text: type: string example: คลองสาน is_address_score: type: number example: 0.99 name: type: object properties: scope: type: array items: type: integer example: - 3 - 26 text: type: string example: ปุญญพัฒน์ เศรษฐ์สมบูรณ์ original_text: type: string example: นายปุญญพัฒน์ เศรษฐ์สมบูรณ์ 081-234-5678 110/1 อาคาร KX (ใกล้ๆ BTS วงเวียนใหญ่) ชั้น 14 ถ.กรุงธนบุรี แขวงบางลำภูล่าง เขตคลองสาน กรุงเทพมหานคร 10600 จ-ศ 10:00-19:00 other: type: string example: นาย 110/1 อาคาร KX (ใกล้ๆ BTS วงเวียนใหญ่) ชั้น 14 ถ.กรุงธนบุรี จ-ศ 10:00-19:00 phone: type: array items: type: object properties: scope: type: array items: type: integer example: - 27 - 39 text: type: string example: 0812345678 postcode: type: object properties: scope: type: array items: type: integer example: - 141 - 146 text: type: string example: '10600' province: type: object properties: scope: type: array items: type: integer example: - 127 - 140 text: type: string example: กรุงเทพมหานคร tambon: type: object properties: scope: type: array items: type: integer example: - 100 - 115 text: type: string example: บางลำภูล่าง test_scope: type: object properties: amphoe: type: string example: เขตคลองสาน name: type: string example: ปุญญพัฒน์ เศรษฐ์สมบูรณ์ phone: type: array items: type: string example: - 081-234-5678 postcode: type: string example: '10600' province: type: string example: กรุงเทพมหานคร tambon: type: string example: แขวงบางลำภูล่าง