Optimizing AnalyzeSyntaxList batch calls
Use AnalyzeSyntaxList to analyze many sentences at once.
This method takes an array of strings (sentences) and returns the analysis result for each sentence, keeping the input order exactly.
It does not split sentences, so the input boundaries are preserved.
This document covers how to raise throughput with AnalyzeSyntaxList and how to track sentence order and position safely. It is
useful when you need to match results to the order or sequence number of the sentences you requested.
Why batch
If you call AnalyzeSyntax once per sentence, you incur one network round trip per sentence.
AnalyzeSyntaxList bundles many sentences into one request and reduces the number of round trips.
graph LR
subgraph Repeated single calls
A1[Sentence 1] --> S1[Request]
A2[Sentence 2] --> S2[Request]
A3[Sentence 3] --> S3[Request]
end
subgraph One batch
B[Array of sentences 1, 2, 3] --> SB[One request]
end
Tracking order and position
AnalyzeSyntaxList does not split sentences, so the i-th sentence in the response corresponds one-to-one to the i-th sentence in the input.
The begin_offset and length in each morpheme's TextSpan are positions within
the corresponding input sentence, and the values change depending on the encoding_type setting.
| Guarantee | Details |
|---|---|
| Order | Input array index = output sentence index |
| Splitting | None (sentence boundaries are preserved) |
| Position | TextSpan.begin_offset is relative to each input sentence and depends on encoding_type |
from bareunpy import Tagger
tagger = Tagger(apikey="koba-XXXX-...", host="api.bareun.ai", port=443)
sentences = [
"오늘 회의는 오후 세시에 시작합니다.",
"내일까지 보고서를 제출해 주세요.",
"감사합니다.",
]
# Analyze the array of sentences at once (order is preserved).
res = tagger.tags(sentences)
for i, sent in enumerate(res.msg().sentences):
print(i, sent.text.content)
curl -s -X POST https://api.bareun.ai/bareun.LanguageService/AnalyzeSyntaxList \
-H "Content-Type: application/json" \
-H "api-key: koba-XXXX-..." \
-d '{
"sentences": ["오늘 회의는 오후 세시에 시작합니다.", "감사합니다."],
"language": "ko_KR",
"encoding_type": "UTF32"
}'
Tips for raising throughput
- Batch size: An array that is too large increases memory use and latency. Group sentences in units of tens to hundreds, and measure to find a suitable size.
- Consistent encoding: Fix
encoding_typeto match your client language's convention (Python usually usesUTF32, JavaUTF16, and Go and C++UTF8). - Concurrency: Sending several batches in parallel raises throughput further through server-side multiplexing.
- Long sentences: Segmentation processes text in 160-character units, so even a long sentence is analyzed.
Use List when order matters
If you need to track "how the Nth line was analyzed," as with logs or documents,
AnalyzeSyntaxList, which involves no sentence splitting, is the safest choice.
Frequently asked questions
Q. Does AnalyzeSyntaxList split sentences again?
No. AnalyzeSyntaxList has no auto_split_sentence option, and it treats each input sentence
as one sentence as given. The input order and boundaries are preserved.
Q. How many sentences can I put in one request?
There is no stated fixed limit, so we recommend measuring to find a suitable batch size, taking memory and latency into account. Sending in units of tens to hundreds of sentences reduces round trips while keeping response latency manageable.
Q. What is the offset based on?
Each morpheme's TextSpan.begin_offset is its position within the corresponding input sentence,
and the value depends on the encoding_type you request (UTF8/UTF16/UTF32).