Skip to content

Logistics

Bills of lading: references, vehicles, sender and receiver with addresses, cargo lines with count, kind and mass, and the totals, in whatever order the document states them.

input.txtHover a value to see its type · click it to find it in the treeRun in Studio
ILLUSTRATIVE FREIGHT RECORD
Bill reference: 104512
Order reference: PO-88213
Dispatch date: 2026-11-09
Truck: 214
Trailer: 5302

Sender: Sample Parts Manufacturing Inc.
Origin: 100 Example Road, Windsor, ON
Sender order: SO-40718
Receiver: Sample Assembly LLC
Destination: 200 Sample Avenue, Detroit, MI

Cargo
12 skids of brake rotors; mass 4,800 kg
2 skids containing brake pads; mass 640 kg

Total: 14 packages; 5,440 kg
Seal: 1234567
Freight payment: Prepaid
logistics.ymlspec
$flags: [ CASE_INSENSITIVE, MULTILINE ]

# Values

Number:
  Grouped:
    $local: { Lead: '\d{1,3}', Group: '\d{3}', Fraction: '\d+' }
    $fields:
      lead: Lead
      groups: { $type: 'Group[]', $separator: ',' }
      fraction: Fraction
    $patterns: '#{lead},#{groups}(\.#{fraction})?'
    $value: '#{lead}#{groups}[.#{fraction}]'
  Plain: '\d+(\.\d+)?'

Date:
  $local:
    Month:
      January: { $patterns: [ 'January', 'Jan\.?' ], $value: '01' }
      February: { $patterns: [ 'February', 'Feb\.?' ], $value: '02' }
      March: { $patterns: [ 'March', 'Mar\.?' ], $value: '03' }
      April: { $patterns: [ 'April', 'Apr\.?' ], $value: '04' }
      May: { $patterns: 'May', $value: '05' }
      June: { $patterns: [ 'June', 'Jun\.?' ], $value: '06' }
      July: { $patterns: [ 'July', 'Jul\.?' ], $value: '07' }
      August: { $patterns: [ 'August', 'Aug\.?' ], $value: '08' }
      September: { $patterns: [ 'September', 'Sept?\.?' ], $value: '09' }
      October: { $patterns: [ 'October', 'Oct\.?' ], $value: '10' }
      November: { $patterns: [ 'November', 'Nov\.?' ], $value: '11' }
      December: { $patterns: [ 'December', 'Dec\.?' ], $value: '12' }
    Year: '(19|20)\d{2}'
    MonthNumber: '0[1-9]|1[0-2]'
    Day: '0[1-9]|[12]\d|3[01]'
  $fields: { year: Year, month: MonthNumber, day: Day }
  $patterns: '#{year}-#{month}-#{day}'
  $value: '#{year}-#{month}-#{day}'
  Written:
    $local: { Day: '[12]\d|3[01]' }
    $fields: { month: Month }
    $patterns:
      - '#{day} #{month},? #{year}'
      - '#{month} #{day},? #{year}'
  WrittenShortDay:
    $local: { Digit: '[1-9]' }
    $fields: { month: Month, digit: Digit }
    $patterns:
      - '0?#{digit} #{month},? #{year}'
      - '#{month} 0?#{digit},? #{year}'
    $value: '#{year}-#{month}-0#{digit}'

MassUnit:
  Kilogram: { $patterns: [ 'kgs?\.?', 'kilograms?', 'kilos?' ], $value: 'kg' }
  Pound: { $patterns: [ 'lbs?\.?', 'pounds?' ], $value: 'lb' }
  Tonne: { $patterns: [ 't', 'tonnes?', 'metric tons?' ], $value: 't' }

MassLabel: '(gross )?(mass|weight|wt\.?)'

Mass:
  $fields: { amount: Number, unit: MassUnit }
  $patterns: '#{amount} ?#{unit}'
  $value: { amount: '#{amount}', unit: '#{unit}' }

PackageKind:
  Skid: { $patterns: 'skids?', $value: 'skid' }
  Pallet: { $patterns: [ 'pallets?', 'plts?\.?' ], $value: 'pallet' }
  Carton: { $patterns: [ 'cartons?', 'ctns?\.?' ], $value: 'carton' }
  Box: { $patterns: [ 'box', 'boxes' ], $value: 'box' }
  Crate: { $patterns: 'crates?', $value: 'crate' }
  Case: { $patterns: [ 'case', 'cases' ], $value: 'case' }
  Drum: { $patterns: 'drums?', $value: 'drum' }
  Bag: { $patterns: [ 'bags?', 'sacks?' ], $value: 'bag' }
  Bundle: { $patterns: 'bundles?', $value: 'bundle' }
  Roll: { $patterns: 'rolls?', $value: 'roll' }
  Tote: { $patterns: 'totes?', $value: 'tote' }
  Piece: { $patterns: [ 'pieces?', 'pcs?\.?' ], $value: 'piece' }
  Package: { $patterns: [ 'packages?', 'pkgs?\.?', 'handling units?' ], $value: 'package' }

PaymentTerms:
  Prepaid: { $patterns: [ 'prepaid', 'pre-paid', 'PPD' ], $value: 'prepaid' }
  Collect: { $patterns: [ 'collect', 'COL' ], $value: 'collect' }
  ThirdParty: { $patterns: [ 'third party', '3rd party' ], $value: 'third party' }

# Labelled lines of the document

Reference:
  $local:
    Code: { $flags: [ -CASE_INSENSITIVE ], $patterns: '[A-Z0-9][A-Z0-9/-]*' }
    NumberWord: '( (no\.?|number|#))?'
  $fields: { code: Code }
  $patterns: '^${Label}${NumberWord}:? #{code}$'
  $value: '#{code}'
  Bill: { $local: { Label: [ 'Bill reference', 'Bill of lading', 'B/?L', 'BOL', 'Bill', 'Pro' ] } }
  Order: { $local: { Label: [ 'Order reference', 'Order', 'Purchase order', 'PO', 'Customer PO', 'Customer order' ] } }
  Truck: { $local: { Label: [ 'Truck', 'Tractor', 'Power unit', 'Unit' ] } }
  Trailer: { $local: { Label: [ 'Trailer' ] } }
  Seal: { $local: { Label: [ 'Seal' ] } }

DispatchDate:
  $local: { Label: [ 'Dispatch date', 'Dispatched', 'Ship date', 'Shipped', 'Shipping date', 'Date shipped', 'Pickup date', 'Date' ] }
  $fields: { date: Date }
  $patterns: '^${Label}:? #{date}$'
  $value: '#{date}'

FreightPayment:
  $local: { Label: [ 'Freight( payment| terms| charges)?', 'Payment terms', 'Terms' ] }
  $fields: { terms: PaymentTerms }
  $patterns:
    - '^${Label}:? #{terms}$'
    - '^#{terms} freight$'
  $value: '#{terms}'

# Parties

Party:
  $local:
    Name: '[^\d\n][^\n]*'
    Address:
      $local:
        Street: { $flags: [ -CASE_INSENSITIVE ], $patterns: '\d+[A-Za-z]?( [^,\n]+)' }
        City: '[^,\n\d]+'
        Region: { $flags: [ -CASE_INSENSITIVE ], $patterns: '[A-Z]{2}' }
        Postal: { $flags: [ -CASE_INSENSITIVE ], $patterns: [ '\d{5}(-\d{4})?', '[A-Z]\d[A-Z] ?\d[A-Z]\d' ] }
        Country: [ 'USA?', 'United States', 'Canada', 'Mexico' ]
      $fields: { street: Street, city: City, region: Region, postal: Postal, country: Country }
      $patterns: '#{street}, #{city},? #{region}( #{postal})?(,? #{country})?'
    Code: { $flags: [ -CASE_INSENSITIVE ], $patterns: '[A-Z0-9][A-Z0-9/-]*' }
    AddressLabel: [ 'Origin', 'Destination', 'Address', 'Pickup', 'Delivery', 'Ship from', 'Ship to' ]
    OrderLabel: '(order|PO|reference|ref\.?)( (no\.?|number|#))?'
  $fields: { name: Name, address: Address, order: Code }
  $patterns: '^${Label}: #{name}(\n((${AddressLabel}: )?#{address}|(${Label} )?${OrderLabel}: #{order}))*$'
  Sender: { $local: { Label: [ 'Sender', 'Shipper', 'Consignor', 'Ship from' ] } }
  Receiver: { $local: { Label: [ 'Receiver', 'Consignee', 'Recipient', 'Ship to' ] } }

# Cargo

CargoLine:
  $local:
    Description: '[^;\n]+?'
    Link: '(of|containing|with)'
  $fields: { count: Number, kind: PackageKind, description: Description, mass: Mass }
  $patterns:
    - '^#{count} #{kind}( ${Link})? #{description}([;,]? (${MassLabel}:? )?#{mass})?$'
    - '^#{description}: #{count} #{kind}([;,]? (${MassLabel}:? )?#{mass})?$'

Totals:
  $before: CargoLine
  $local:
    Total: 'totals?'
  $fields: { packages: Number, kind: PackageKind, mass: Mass }
  $patterns:
    - '^${Total}:? (#{packages} #{kind}([;,]? #{mass})?|#{mass})$'
    - '^(${Total} (#{kind}:? #{packages}|${MassLabel}:? #{mass})\n?)+$'

# The document

Shipment:
  $local: { Other: '[^\n]+' }
  $fields:
    bill: Reference::Bill
    order: Reference::Order
    dispatchDate: DispatchDate
    truck: Reference::Truck
    trailer: Reference::Trailer
    sender: Party::Sender
    receiver: Party::Receiver
    cargo: 'CargoLine[]'
    totals: Totals
    seal: Reference::Seal
    payment: FreightPayment
  $patterns: '^((#{bill}|#{order}|#{dispatchDate}|#{truck}|#{trailer}|#{sender}|#{receiver}|#{cargo}|#{totals}|#{seal}|#{payment}|${Other})\n*)+'
$ texomy parse input.txt -m logistics
logistics.json
[
  {
    "type": "Shipment",
    "start": 0,
    "end": 463,
    "fields": {
      "bill": {
        "type": "Reference::Bill",
        "start": 28,
        "end": 50,
        "fields": {
          "code": {
            "type": "Code",
            "start": 44,
            "end": 50,
            "text": "104512"
          }
        },
        "value": "104512"
      },
      "order": {
        "type": "Reference::Order",
        "start": 51,
        "end": 76,
        "fields": {
          "code": {
            "type": "Code",
            "start": 68,
            "end": 76,
            "text": "PO-88213"
          }
        },
        "value": "PO-88213"
      },
      "dispatchDate": {
        "type": "DispatchDate",
        "start": 77,
        "end": 102,
        "fields": {
          "date": {
            "type": "Date",
            "start": 92,
            "end": 102,
            "fields": {
              "year": {
                "type": "Year",
                "start": 92,
                "end": 96,
                "text": "2026"
              },
              "month": {
                "type": "MonthNumber",
                "start": 97,
                "end": 99,
                "text": "11"
              },
              "day": {
                "type": "Day",
                "start": 100,
                "end": 102,
                "text": "09"
              }
            },
            "value": "2026-11-09"
          }
        },
        "value": "2026-11-09"
      },
      "truck": {
        "type": "Reference::Truck",
        "start": 103,
        "end": 113,
        "fields": {
          "code": {
            "type": "Code",
            "start": 110,
            "end": 113,
            "text": "214"
          }
        },
        "value": "214"
      },
      "trailer": {
        "type": "Reference::Trailer",
        "start": 114,
        "end": 127,
        "fields": {
          "code": {
            "type": "Code",
            "start": 123,
            "end": 127,
            "text": "5302"
          }
        },
        "value": "5302"
      },
      "sender": {
        "type": "Party::Sender",
        "start": 129,
        "end": 229,
        "fields": {
          "name": {
            "type": "Name",
            "start": 137,
            "end": 168,
            "text": "Sample Parts Manufacturing Inc."
          },
          "address": {
            "type": "Address",
            "start": 177,
            "end": 206,
            "fields": {
              "street": {
                "type": "Street",
                "start": 177,
                "end": 193,
                "text": "100 Example Road"
              },
              "city": {
                "type": "City",
                "start": 195,
                "end": 202,
                "text": "Windsor"
              },
              "region": {
                "type": "Region",
                "start": 204,
                "end": 206,
                "text": "ON"
              }
            }
          },
          "order": {
            "type": "Code",
            "start": 221,
            "end": 229,
            "text": "SO-40718"
          }
        }
      },
      "receiver": {
        "type": "Party::Receiver",
        "start": 230,
        "end": 303,
        "fields": {
          "name": {
            "type": "Name",
            "start": 240,
            "end": 259,
            "text": "Sample Assembly LLC"
          },
          "address": {
            "type": "Address",
            "start": 273,
            "end": 303,
            "fields": {
              "street": {
                "type": "Street",
                "start": 273,
                "end": 290,
                "text": "200 Sample Avenue"
              },
              "city": {
                "type": "City",
                "start": 292,
                "end": 299,
                "text": "Detroit"
              },
              "region": {
                "type": "Region",
                "start": 301,
                "end": 303,
                "text": "MI"
              }
            }
          }
        }
      },
      "cargo": [
        {
          "type": "CargoLine",
          "start": 311,
          "end": 350,
          "fields": {
            "count": {
              "type": "Number::Plain",
              "start": 311,
              "end": 313,
              "text": "12"
            },
            "kind": {
              "type": "PackageKind::Skid",
              "start": 314,
              "end": 319,
              "text": "skids",
              "value": "skid"
            },
            "description": {
              "type": "Description",
              "start": 323,
              "end": 335,
              "text": "brake rotors"
            },
            "mass": {
              "type": "Mass",
              "start": 342,
              "end": 350,
              "fields": {
                "amount": {
                  "type": "Number::Grouped",
                  "start": 342,
                  "end": 347,
                  "fields": {
                    "lead": {
                      "type": "Lead",
                      "start": 342,
                      "end": 343,
                      "text": "4"
                    },
                    "groups": [
                      {
                        "type": "Group",
                        "start": 344,
                        "end": 347,
                        "text": "800"
                      }
                    ]
                  },
                  "value": "4800"
                },
                "unit": {
                  "type": "MassUnit::Kilogram",
                  "start": 348,
                  "end": 350,
                  "text": "kg",
                  "value": "kg"
                }
              },
              "value": {
                "amount": "4800",
                "unit": "kg"
              }
            }
          }
        },
        {
          "type": "CargoLine",
          "start": 351,
          "end": 393,
          "fields": {
            "count": {
              "type": "Number::Plain",
              "start": 351,
              "end": 352,
              "text": "2"
            },
            "kind": {
              "type": "PackageKind::Skid",
              "start": 353,
              "end": 358,
              "text": "skids",
              "value": "skid"
            },
            "description": {
              "type": "Description",
              "start": 370,
              "end": 380,
              "text": "brake pads"
            },
            "mass": {
              "type": "Mass",
              "start": 387,
              "end": 393,
              "fields": {
                "amount": {
                  "type": "Number::Plain",
                  "start": 387,
                  "end": 390,
                  "text": "640"
                },
                "unit": {
                  "type": "MassUnit::Kilogram",
                  "start": 391,
                  "end": 393,
                  "text": "kg",
                  "value": "kg"
                }
              },
              "value": {
                "amount": "640",
                "unit": "kg"
              }
            }
          }
        }
      ],
      "totals": {
        "type": "Totals",
        "start": 395,
        "end": 423,
        "fields": {
          "packages": {
            "type": "Number::Plain",
            "start": 402,
            "end": 404,
            "text": "14"
          },
          "kind": {
            "type": "PackageKind::Package",
            "start": 405,
            "end": 413,
            "text": "packages",
            "value": "package"
          },
          "mass": {
            "type": "Mass",
            "start": 415,
            "end": 423,
            "fields": {
              "amount": {
                "type": "Number::Grouped",
                "start": 415,
                "end": 420,
                "fields": {
                  "lead": {
                    "type": "Lead",
                    "start": 415,
                    "end": 416,
                    "text": "5"
                  },
                  "groups": [
                    {
                      "type": "Group",
                      "start": 417,
                      "end": 420,
                      "text": "440"
                    }
                  ]
                },
                "value": "5440"
              },
              "unit": {
                "type": "MassUnit::Kilogram",
                "start": 421,
                "end": 423,
                "text": "kg",
                "value": "kg"
              }
            },
            "value": {
              "amount": "5440",
              "unit": "kg"
            }
          }
        }
      },
      "seal": {
        "type": "Reference::Seal",
        "start": 424,
        "end": 437,
        "fields": {
          "code": {
            "type": "Code",
            "start": 430,
            "end": 437,
            "text": "1234567"
          }
        },
        "value": "1234567"
      },
      "payment": {
        "type": "FreightPayment",
        "start": 438,
        "end": 462,
        "fields": {
          "terms": {
            "type": "PaymentTerms::Prepaid",
            "start": 455,
            "end": 462,
            "text": "Prepaid",
            "value": "prepaid"
          }
        },
        "value": "prepaid"
      }
    }
  }
]

About this spec

Bills of lading and freight records: references, dispatch date, truck and trailer, sender and receiver with address and order number, cargo lines with package count, kind, description and mass, totals, seal and freight payment terms.

Package files

  • logistics.yml
  • samples/bill-of-lading.txt
  • samples/compact-bol.txt
  • samples/freight-record.txt
  • samples/memo.txt
  • tests/expected/bill-of-lading.yaml
  • tests/expected/compact-bol.yaml
  • tests/expected/freight-record.yaml
  • tests/expected/input.yaml
  • tests/expected/memo.yaml
  • tests/lines.test.yml
  • tests/logistics.test.yml
  • texomy.json

55 nodes from 1 top-level matches.

Run it yourself

Save the example from Studio to a folder, then in that folder:

texomy parse input.txt -m logistics
texomy test

Write the spec once. Run it on everything.

Install the CLI, connect your agent, and turn your first sample into typed data in minutes.

brew install texomy/tap/texomy