"Understanding" the synonym behaviour in group context

(Philipp Fink) #1

Hi guys,
I am finally playing around with HABot and it really is great! Thanks so much for that, it does immediately adds tremendous show-off-potential :slight_smile:
I am confused though, I have read the walkthrough, especially part 2, but it does not want to do what I expect.

I have this simple setup:

Group G_Sensors                      "Sensoren"                          ["Measurement"]
Group G_Humidity                     "Luftfeuchtigkeit"      (G_Sensors) ["Humidity"]
Group G_OG                           "OG"                                ["FirstFloor"]
Group G_Lukasbedroom                 "Lukas Zimmer"          (G_OG)      ["Room"]                       { synonyms="Kinderzimmer" } 
Number lukasbedroom_Sensor2_Humidity "Kinderzimmer Luftfeuchtigkeit [%d %%]" (G_Lukasbedroom, G_Humidity)   {channel="zwave:device:1eb9918f:node13:sensor_relhumidity" }

And If I ask the bot to find “wie ist die Luftfeuchtigkeit im Kinderzimmer” or “wie ist die Luftfeuchtigkeit im Lukas Zimmer”, it cannot tell.

I eventually created a custom Card that contains both locations, Kinderzimmer and Lukas Zimmer, as well es objects feuchtigkeit and luftfeuchtigkeit, but even that only works if I ask “Wie ist die (Luft-)Feuchtigkeit”, and not “Wie ist die (Luft-)Feuchtigkeit im Kinderzimmer” . As soon as I add the Location, it will fail.

It seems to work a little, because Luftfeuchtigkeit is not a common tag, I assume it was determined by the parents group’s name.

Then, to add to the strangeness, I changed the tag of G_Lukasbedroom from [“Room”] to [“Bedroom”], and it finally understands “Wie ist die Luftfeuchtigkeit im Lukas Zimmer”… But it does not understand “Wie ist die Luftfeuchtigkeit im Kinderzimmer”…

Can somebody spot my problem?

Thanks in Advance,
best regards


(Yannick Schaus) #2

Hi Phil,

The thing is, except for location tags, you can’t expect semantic tags applied on groups to propagate to group members. This is how it used to work when HABot was in beta but after some debate on GitHub, basically now you have to specify directly the Point and Property tags on each item for it to be correctly recognized.

In your case, this should work better:

Group G_Sensors                      "Sensoren"
Group G_Humidity                     "Luftfeuchtigkeit"      (G_Sensors)
Group G_OG                           "OG"                                ["FirstFloor"]
Group G_Lukasbedroom                 "Lukas Zimmer"          (G_OG)      ["Bedroom"]                       { synonyms="Kinderzimmer" } 
Number lukasbedroom_Sensor2_Humidity "Kinderzimmer Luftfeuchtigkeit [%d %%]" (G_Lukasbedroom, G_Humidity)  ["Measurement", "Humidity"]  {channel="zwave:device:1eb9918f:node13:sensor_relhumidity" }

If you have other types of sensors you’ll have to specify both “Measurement” and the appropriate property tag on each of them. Make sure you see the logs from OpenNLP (a whole lot of “loglikelihood=” lines in the logs), that means it has retrained itself with the new data including synonyms from your items - that can help a lot. If not restart the HABot bundle (bundle:list | grep HABot in the console then bundle:restart <num>).
Finally you can set the log to debug with log:set DEBUG org.openhab.ui.habot, there will be more information on what intent & entities were recognized.


(Philipp Fink) #3

New day, new hopes :smiley: Thanks for the very quick answer!

I am unsure whether you understood my problem or if I understood your answer. :slight_smile: So I will be more detailed.

My problem (I think) is with the location (not the measurement): It does get the intent (name=get-status) correctly, even though the Tag is on the parent. So let’s focus more in the location that I am worried about:

After more try and error, I have found 3 Parts of my problem:
Part 1: Room vs Bedroom.

I ask habot

"Wie ist die Temperatur im Kinderzimmer" (what is the humidity in lukas room).

In my understanding, the location “Bedroom” is a subthing from a “Room” - but I do get different results between those to variants:

Group G_Lukasbedroom                 "Lukas Zimmer"          (G_OG)      ["Bedroom"]                       { synonyms="Kinderzimmer" } 

(Intent [name=get-status, entities={location=kinderzimmer, object=luftfeuchtigkeit}])


Group G_Lukasbedroom                 "Lukas Zimmer"          (G_OG)      ["Room"]                       { synonyms="Kinderzimmer" } 

Intent [name=get-status, entities={object=luftfeuchtigkeit}]

As if synonyms do not work on Rooms, only on Bedrooms? Is this intended?

Part 2: Spaces in location names
If the location consists of 2 Names, It does not work properly.

Group G_Demo1   "roomwithnospace"   ["Bedroom"] 
Number demoitem1 "demo item in room with no space" (G_Demo1) ["Temperature", "Measurement"]
Group G_Demo2   "room with space"   ["Bedroom"] 
Number demoitem2 "demo item in room with space" (G_Demo2) ["Temperature", "Measurement"]
Group FF_Son     "Oliver's Room"  ["Bedroom"]  { synonyms="Oli's Room" }
Number demoitem3 "demo item bei Oli" (FF_Son) ["Temperature", "Measurement"]

Only the room with no spaces can be addressed:

Wie ist die Temperatur im room with space -> Intent [name=get-status, entities={object=temperatur}]
Wie ist die Temperatur im roomwithnospace -> Intent [name=get-status, entities={location=roomwithnospace, object=temperatur}]
Wie ist die Temperature in/im Oli's Room  -> Intent [name=get-status, entities={location=room, object=temperature}]

I included the example of the workthrough, I assume that is related to the german language?

Part 3: german specific: in vs im.
Sometimes we say “in”, sometimes we say “im”. It is for example:

ist die Temperatur "im" Kinderzimmer -> Intent [name=get-status, entities={location=kinderzimmer, object=temperatur}]

And openhab works correct! But if we have to name to room with 2 words, we use a different preposition:

wie ist die Temperatur "in" Lukas' Zimmer.  -> Intent [name=get-status, entities={value=lukas', object=temperatur}]

Here the location fails.

But we would never say:

wie ist die Temperatur "im" Lukas' Zimmer -> Intent [name=get-status, entities={location=lukas' zimmer, object=temperatur}]

Although Habot would understand that.

I assume this nuonce of german in Part 2 and 3 has to be added to the model - how/where do I address that?

Thanks again,


(Mark) #4

Sorry to impose on this thread, but I have just a quick question for clarification. In addition to Point and Property, is it also true that Equipment doesn’t propagate to group members?


(Yannick Schaus) #5

No, synonyms should work on items tagged Room - they are locations too.
The basic problem with custom synonyms is that they are often not part of the original training data for the entity extraction part of the NLP - for the get-status intent in German, it’s here. The idea with machine learning algorithms like these is, the more training data, the better it will perform. As you can see currently it consists of 50 sentences (only), and the algorithm is supposed to learn how to recognize this intent AND extract entities from that. I should add, labels and synonyms of tagged entities are fed to the trainer at runtime to aid in their recognition, but even with that, it might not always be enough…

That’s right, to add to the training data you simply add as many sentences as you can come up with to the .txt files of the corresponding intent. This has to be done with a PR on GitHub however, with an associated test suite (https://github.com/openhab/openhab-webui/blob/master/org.openhab.ui.habot/src/test/java/org/openhab/ui/habot/test/TrainerDeTest.java) for the language - adding more training data for one of the intents might decrease the accuracy of the recognition for the other intents, so we must be careful. One day I will add the ability to read text files from the local filesystem so that users might experiment and influence the training without having to recompile.

Yes, Equipments are normally set either on individual non-group items, or on group items with members tagged as Points, so we can’t propagate the Equipment tag to members or those members would be both Points and Equipments, which isn’t supported by the model. The only thing supported by the semantic service right now is “is this item in this location”, which will use the group hierarchy.
However (this is a purely HABot-specific behavior, not a feature of the core semantics package) if the semantic query resolves to a group item, then the group will be expanded to its member items in the resulting card.

1 Like

(Philipp Fink) #6

Dear Yannick,
sorry for my late response, soo much topics that I was working on at the same time - not healthy by the way :slight_smile:

I just wanted to say that this clearification was very helpful for me. I assume that knowing where to look for the trained sentences is helpful for every user to understand how to formulate the questions. - and in general, how that text-understanding works. was not clear before your post, was clear after your post.

Unfortunately, I have to pass on helping on “more sentences”. But I love the way the solution is set up with the unit tests and stuff. I could hardly find the time to answer your post, will definately not find the time for this now. Priority is to have my house build. But I am looking to come back to this topic.
Best regards

1 Like