question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is your feature request related to a problem? Please describe. I’m super impressed by your product. Really amazing offering, and great experience.

My question: is it possible to make slot optional for matching? I.e. allow the expression to be matched even if slot was not matched? My example

[open, extend, slide out] (the, a) $zone:zone (hydraulic, hydraulics, slide out, slide outs, room, section, slide, slides, cylinder, cylinders, areas, areas) (completely, entirely, fully, to the max, hundred percent, to the limit, as much as possible)

So I have only one meaningful $zone slot here, but also I have a set of words that I don’t care that much for, but they can be in the command. Because i have a bunch of intents and commands reusing those sets, i’d love to turn them into slots for reuse, while basically ignoring them later. The problem is that I’d like the command to work even if they are not matched.,

Describe the solution you’d like ($zone:zone) type syntax for optional slots

Describe alternatives you’ve considered I can use multiple separate commands with or without slots, but there’s combinatorial complexity to support them all. I can also keep listing them as is which makes commands hard to parse visually

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ErisMikcommented, Jan 20, 2022

Yes that is correct, Macros and Slots can be used in the same way throughout the expressions, and follow the same rules within Choices and Optionals. The only functional difference is if the matched value is present in the output. In your case with the min and max, since you want the output, Slots inside an Optional or Choice is definitely the way to go.

Macros are good to use as an alias for a Choice (eg. @brew instead of [make, brew, pour] ), to reduce writing the same entries in multiple expressions. But obviously because they can be embedded in other Choice and Optional constructs, they are quite flexible.

1reaction
ErisMikcommented, Jan 18, 2022

I’m happy to say that we’ve implemented two additional features that should help with some of your concerns. Firstly, the addition of “Macros”, and secondly the ability to use both Macros and Slots in Optional and choice constructs. Full documentation is coming but in the meantime, some examples should be enough to get you started.

For the example you provided in the issue: [open, extend, slide out] (the, a) $zone:zone (hydraulic, hydraulics, slide out, slide outs, room, section, slide, slides, cylinder, cylinders, areas, areas) (completely, entirely, fully, to the max, hundred percent, to the limit, as much as possible)

You can now reduce it to something like: @openOptions (the, a) $zone:zone (@terms) (@stateMax) with your YAML as so:

context:
  expressions:
    myIntent:
      - "@openOptions (the, a) $zone:zone (@terms) (@stateMax)"
  slots:
    zone:
      - zone one
      - zone two
      - zone three
  macros:
    openOptions:
      - open
      - extend
      - slide out
    terms:
      - hydraulic
      - slide outs
      - room
      - section
    stateMax:
      - completely
      - entirely
      - fully
      - to the max

Macros and Slots can be mixed and matched within the Optional and Choice constructs:

($close:close, $open:open, change) (the, a) [$zone:zone, all] (@term) (@minAliases, @maxAliases, $state:state)

These changes are live and hopefully this should help with more complex grammers like you have mentioned here. As usual, if you you run into any additional problems please feel free to open another issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

English Grammar Lecture 8: Optional Slots - SlideShare
In other words, the slot is optional and whether the element is present in the surface sentence or not the sentence is still...
Read more >
English Grammar Lecture 8: Optional Slots - ppt download
In other words, the slot is optional and whether the element is present in the surface sentence or not the sentence is still...
Read more >
Optional slots - Rasa Open Source
Hi,. I wonder what's the best way of creating slots, that are not obligatory. What I mean by that? Let me define a...
Read more >
add possibility to define optional slots for forms #6939 - GitHub
E.g. by doing the following, a slot would be allowed for a form, but not required - so optional slots? slots: location: type:...
Read more >
Component composition / Checking for slot content • Svelte ...
You can do this by checking the properties of the special $$slots variable. $$slots is an object whose keys are the names of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found