Christian Gawron
Christian Gawron

Reputation: 841

Rules / Regexp in Watson Knowledge Studio

I need to formulate a set of rules and regular expressions in WKS to identify song title and artist in sentences like "Play Locomotive Breath" or "Play the song Locomotive Breath by Jethro Tull" (I actually do this for German, so I can't use builtin entities in NLU).

My problem is that the "by " part is optional. I have set up regular expressions for the German equivalents of "Play [the song]" (mapping to a class PLAY) and "by" (mapping to a class BY) and tried to add two rules, one matching PLAY (any tokens) BY (any tokens) and PLAY (any tokens). The problem is that the second rule also matches when the first one does, so that in the sentence "Play Locomotive Breath by Jethro Tull" the title is recognized as "Locomotive Breath by Jethro Tull".

I tried to define a regular expression with negative lookahead, i.e. (\w* (?!(by)))* to match the text up the "by", but this does not seem to work in WKS.

Any ideas how I can extract song titles and artists using WKS rules?

Upvotes: 0

Views: 368

Answers (1)

Teruki Tauchi
Teruki Tauchi

Reputation: 46

Regular expressions with negative lookahead should work fine in WKS.

I am not sure if your regular expression (\w* (?!(by)))* expresses what you intended. Is it working as you expected outside of WKS?

Maybe you meant something like ((?!(by))\w)* ?

Upvotes: 1

Related Questions