Extraction Guide
This guide covers advanced extraction techniques for the AISAY Web Portal, including tables, conditional extraction, correcting mistakes, and working with related or nested values.
Prerequisite: Read the Quick Start Guide and Using Objects first.
Extracting Tables and Repeating Rows
Tables are one of the most common extraction challenges. The key insight is that each row in a table is an Object, and the table itself is a List of those Objects.
Scenario: Extract all rows from a timesheet.
Structure:
Timesheet Results (List)
└─ Timesheet Row (Object)
├─ Date (Text) — "The date of the entry, e.g. 11 May 2025"
├─ Employee Number (Text) — "The employee number, e.g. 23234"
└─ Remarks (Text) — "Any remarks or notes written for this entry"Portal setup:
| Level | Data Label | Type | Prompt |
|---|---|---|---|
| Top | Timesheet Results | List | Extract all timesheet rows |
| Nested | Timesheet Row | Object | Each row in the timesheet |
| Object field | Date | Text | The date of the entry in the format 11 May 2025 |
| Object field | Employee Number | Text | The employee number, e.g. 23234 |
| Object field | Remarks | Text | Any remarks or notes written for this entry |
Another Example: Board Members from an Annual Report
Structure:
Board Information (List)
└─ Board Member (Object)
├─ Name (Text) — "The name of the board member"
├─ Salutation (Text) — "The salutation, e.g. Mr, Mrs, Dr"
├─ Designation (Text) — "The board designation or title"
├─ Gender (Text) — "The gender of the board member, if available"
└─ Expertise (Text) — "Their area of expertise, if stated in the report"Tip: Add “if available” or “if stated in the report” to fields that may not always be present. This prevents the AI from guessing.
Conditional Extraction
Sometimes the value you need to extract depends on another part of the document.
Scenario: A form has three options (Resolution, Court Order, Others). Only one is selected. Depending on the selection, you need the date from the corresponding section.
Solution: Use multiple fields that reference each other.
Field 1 — Determine the selection:
| Setting | Value |
|---|---|
| Data Label | selected_option |
| Data Type | Text |
| Prompt | In the section ‘Alteration of constitution information’ look at ‘Type of document’. Exactly one of the 3 options (a) Resolution, (b) Court order, (c) Others will be selected or filled. Return EXACTLY one of these lowercase labels: ‘resolution’, ‘court_order’, or ‘others’. If it is unclear, choose the best guess. |
Field 2 — Extract the date conditionally:
| Setting | Value |
|---|---|
| Data Label | form_primary_date |
| Data Type | Text |
| Prompt | Depending on the selected option, extract ONE main date from the relevant section and format it as DD/MM/YYYY: If ‘resolution’ is selected, return the ‘Date of meeting’. If ‘court_order’ is selected, return the ‘Date of court order’. If ‘others’ is selected, return the ‘Date of document’. If no date is clearly present, return an empty string. |
Field 3 — Extract the effective date conditionally:
| Setting | Value |
|---|---|
| Data Label | form_effective_date |
| Data Type | Text |
| Prompt | Depending on the selected option, extract the ‘Effective date’ field from the same section, and format it as DD/MM/YYYY where possible. If no clear effective date is present, return an empty string. |
Correcting Common Mistakes
If the AI consistently misreads a value, guide it in your prompt. Treat it like instructing a colleague — explain what commonly goes wrong.
Scenario: A licence number’s third character is frequently misread as “1” instead of lowercase “l” due to the font.
| Setting | Value |
|---|---|
| Data Label | licence_no |
| Data Type | Text |
| Prompt | Licence Number. Note that due to the font used, a lot of the times the third character of the license number is misread — it should be an l (lowercase L) instead of a 1 (the number one). Please note and follow if in doubt. |
Tips for fixing mistakes:
- Tell the AI about known patterns or formats (e.g., “The licence number always starts with two digits, followed by a letter”)
- Provide examples of correct values
- Specify the expected format explicitly (e.g., “DD/MM/YYYY”, “S1234567A”)
- If one model makes more mistakes, try the other model
Extracting Related Values
When values come in pairs or groups (e.g., phone numbers with their data usage), you need to maintain the association between them. Using separate List fields for each value won’t work — the lists may not line up if some entries are missing a value.
The solution is to use a List of Objects, where each Object groups the related values together.
Scenario: Extract mobile numbers and their associated data usage from a corporate phone bill.
Structure:
Number Data Pairs (List)
└─ Number_Data (Object)
├─ Phone Number (Text) — "The phone number, e.g. 91234567"
└─ Local Data Usage (Text) — "The local data usage, e.g. 5kb. If none, return 0."Portal setup:
| Level | Data Label | Type | Prompt |
|---|---|---|---|
| Top | Number Data Pairs | List | Extract the list of mobile numbers and their associated local data usage. Note that the local data usage may be in KB or MB. If there isn’t a local data usage, return 0. |
| Nested | Number_Data | Object | Each phone number and its data usage |
| Object field | Phone Number | Text | The phone number, e.g. 91234567 |
| Object field | Local Data Usage | Text | The local data usage, e.g. 5kb. If none, return 0. |
Extracting Nested Values
When data is nested — a section contains a sub-list of unknown length — the same List + Object pattern applies.
Scenario: An incident report lists parties involved in a car accident. There could be 2, 3, or more parties, and each party has a name, vehicle number, and age.
Structure:
Date of Incident (Text)
Location of Incident (Text)
Agency Involved (Text)
Parties Involved (List)
└─ Party (Object)
├─ Name (Text) — "The name of the party, e.g. Tan Xiao Ming"
├─ Vehicle Number (Text) — "The vehicle plate number, e.g. SYY2313G"
└─ Age (Number) — "The age of the person, e.g. 34"Portal setup:
| Level | Data Label | Type | Prompt |
|---|---|---|---|
| Top | Date of Incident | Text | The date of the incident in DD/MM/YYYY format |
| Top | Location of Incident | Text | The location where the incident occurred |
| Top | Agency Involved | Text | The agency involved in the incident |
| Top | Parties Involved | List | All parties involved in the incident. Note there could be more than one party. |
| Nested | Party | Object | Each party involved in the incident |
| Object field | Name | Text | The name of the party, e.g. Tan Xiao Ming |
| Object field | Vehicle Number | Text | The vehicle plate number, e.g. SYY2313G |
| Object field | Age | Number | The age of the person, e.g. 34 |
This shows how you can combine simple top-level fields (Date, Location, Agency) with a List of Objects (Parties) in the same extraction run.
Tip: If you know the exact number of items (e.g., a form always has exactly 2 parties), you can skip Objects and just use flat fields:
Party1_Name,Party1_Vehicle,Party2_Name,Party2_Vehicle, etc. Objects are most useful when the count is variable.
See Also
- Quick Start Guide — Basics of the web portal
- Using Objects — Full guide on Lists and Objects
- Prompt Writing Tips — Write better prompts
- Analysis Guide — Go beyond extraction to evaluation