PathExpressions

28 views
Skip to first unread message

Richard Dijkstra

unread,
Aug 7, 2023, 2:57:25 PM8/7/23
to LinkML
Good evening,

I have made some models and came along the PathExpression class and asked ChatGPT how to use this.

Having the classes Country and City
Is the following answer by ChatGP correct?

The question I stated was:
- Make a linkml model with country and city class
Followed by:
- Use a PathExpression

name: CountriesAndCities
description: A simple model for representing countries and cities
license: CC0
default_prefix: cc

imports:
  - linkml:types

types:
  string:
    base: string
    description: A textual string
  integer:
    base: integer
    description: An integer number

classes:
  Country:
    description: Represents a country
    attributes:
      name:
        type: string
        description: The name of the country
      population:
        type: integer
        description: The population of the country
      capital:
        type: City
        description: The capital city of the country
        path: cc.City[country=cc.Country.name]

  City:
    description: Represents a city
    attributes:
      name:
        type: string
        description: The name of the city
      population:
        type: integer
        description: The population of the city
      country:
        type: Country
        description: The country to which the city belongs
        path: cc.Country[capital=cc.City.name]

Country:
  - id: country1
    name: United States
    population: 331000000
    capital: city1

  - id: country2
    name: Canada
    population: 37590000
    capital: city2

  - id: country3
    name: United Kingdom
    population: 67886011
    capital: city3

City:
  - id: city1
    name: Washington, D.C.
    population: 702455

  - id: city2
    name: Ottawa
    population: 994837

  - id: city3
    name: London
    population: 8982000


Reply all
Reply to author
Forward
0 new messages