|
|
|
def parse_id_card(text, validation_type, entities=None): |
|
if validation_type == "身分證正面": |
|
result = { |
|
"解析全文內容": text, |
|
"姓名": entities.get('B-PER', '無法解析') if entities else '無法解析', |
|
"出生年月日": entities.get('B-DATE', '無法解析') if entities else '無法解析', |
|
"發證日期": entities.get('I-DATE', '無法解析') if entities else '無法解析', |
|
"統一編號": entities.get('B-NUM', '無法解析') if entities else '無法解析' |
|
} |
|
elif validation_type == "身分證反面": |
|
result = { |
|
"解析全文內容": text, |
|
"父": entities.get('B-FATHER', '無法解析') if entities else '無法解析', |
|
"母": entities.get('B-MOTHER', '無法解析') if entities else '無法解析', |
|
"配偶": entities.get('B-SPOUSE', '無法解析') if entities else '無法解析', |
|
"出生地": entities.get('B-LOC', '無法解析') if entities else '無法解析', |
|
"住址": entities.get('I-LOC', '無法解析') if entities else '無法解析', |
|
"編號": entities.get('B-ID', '無法解析') if entities else '無法解析' |
|
} |
|
else: |
|
result = { |
|
"解析全文內容": text, |
|
} |
|
|
|
return result |