Patterns Files Structure

PATTERNS

The Cariochi Patterns service adopts the YAML format to define classes and their associated text patterns, providing users with a flexible and intuitive way to customize and expand the service's capabilities effectively.

imports Section

The "imports" section allows users to include other YAML files within the current file, facilitating the reuse of existing classes and patterns. This modularity ensures that patterns can be easily shared and applied across various contexts.

classes Section

The heart of the pattern file lies within the "classes" section, where users define specific classes and their corresponding text patterns. Each class can have multiple patterns associated with it, enhancing the service's ability to recognize diverse entities in the input text.

Users can define hierarchical classes in the pattern file using YAML format, enabling the organization of related classes in a structured manner with any depth of hierarchy.

Example Pattern Files

Below are examples showcasing the structure of pattern files in the Cariochi Patterns service:

common/numbers.yml
classes:

  Number:
    Real:
      - "\d+\.\d+"
    Integer:
      - "\d+"
common/datetime.yml
imports:
  - numbers

classes:

  Date:
    - "~{#year: 2000}-{#month: 05}-{#day: 10}"
    - "~{#month: 07}/{#day: 12}/{#year: 2020}"
    - "~{#month: November} {#day: 1}(?:st|nd|rd|th)?, {#year: 1991}"

  Month:
    - January
    - February
    - March
    - April
    - May
    - June
    - July
    - August
    - September
    - October
    - November
    - December

  TimePeriod:
    AM:
      - "(?-i)AM"
    PM:
      - "(?-i)PM"

  Time:
    - "~{#hours: 1}:{#minutes: 30}\s?{#period: AM}"
    - "~{#hours: 13}:{#minutes: 00}"
common/currencies.yml
imports:
  - numbers

classes:

  Currency:
    USD:
      - $
    EUR:
      - €
    POUND:
      - Β£

  Money:
    - "~€1"
patterns.yml
imports:
  - common/datetime
  - common/currencies

classes:

  MeetingInfo:
    - "~meeting starts at {#startTime: 00:00}"
    - "~meeting is scheduled for {#startTime: 00:00}"

More examples on demo.cariochi.com

Last updated