Skip to content

Commit 08b1b86

Browse files
Copilotwannaphong
andcommitted
Add validation to ensure at least 10 fields in dependency parsing output
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
1 parent 39ea09c commit 08b1b86

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

spacy_pythainlp/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ def _dep(self, doc:Doc):
165165
_dep_temp = dependency_parsing(text, model=self.dependency_parsing_model, engine=self.dependency_parsing_engine, tag="list")
166166
for i in _dep_temp:
167167
# Handle variable number of fields returned by dependency_parsing
168+
# CoNLL-U format requires at least 10 fields, but some engines may return more
169+
if len(i) < 10:
170+
raise ValueError(f"Expected at least 10 fields in dependency parsing output, got {len(i)}")
168171
# Only unpack the first 10 fields we need (CoNLL-U format)
169172
idx, word, _, postag, _, _, head, dep, _, space = i[:10]
170173
words.append(word)

0 commit comments

Comments
 (0)