Noun Phrases

Learn about the concept of a noun phrase in the BDK.

Overview

A noun phrase is a group of words centered around a noun. It consists of:

  • Head: The main noun representing the data.
  • Modifiers: Optional words providing additional context to the head noun.

The NounPhase class can be used to represent a noun phrase.


Modifiers

A modifier is an optional part of a noun phrase that provides additional detail about the head noun. It appears before the head and refines the data being referenced.

Example: Creating a Noun Phrase with Modifiers

# Create a noun phrase with a head and modifiers
np = NounPhrase("dog", ["big", "white"])
print(np)  # Outputs: big white dog

In this example:

  • Head: "dog"
  • Modifiers: "big", "white"

The resulting noun phrase is "big white dog".


Parameters as Noun Phrases

Parameters can be defined as NounPhrase types to tell the system to use a data element's name instead of its value.

Example: Defining a Parameter as a Noun Phrase

Consider the following operation method definition, where the city parameter is defined as a NounPhrase:

@procedure("to get the (current temperature) at a city")
def current_temperature(
  self, city: NounPhrase, unit: Optional[NounPhrase] = NounPhrase("metric")
) -> float:

This operation can be called in an automation where London is a data element with a specific value:

London is "windy"
get the current temperature at London

In this example, when London is specified as the city parameter, the system uses the data's name (London) instead of its value ("windy").