This repository has been archived by the owner on May 23, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transition to metadata & semantic tags understanding
This introduces BREAKING CHANGES! Following the discussion in eclipse-archived/smarthome#1093 the mechanism matching the entities extracted by OpenNLP from the natural language query to ESH items is being altered in this way: 1. Tags are not the primary conduit for item identification: this change introduces the concept of "Named Attributes" which will be implicitely affixed to items by a new class/ OSGi component, the `ItemNamedAttributesResolver` 2. Tags are now expected to conform to a semantic tag library: the current version is at https://github.com/eclipse/smarthome/wiki/Semantic-Tag-Library HABot has internal translations for the most useful semantic tags in the languages it understands and will derive named attributes for items from those `tagattributes_{locale].properties` resource bundles 3. In addition to tags, users may specify additional "monikers" for items by using metadata in the "habot" namespace: ``` Group FF_ChildsRoom { habot="Amy's room" [type="location"] } ``` Those monikers will also be added to item's named attributes set. The "type" configuration property is optional: if left unspecified, monikers will have the "object" type. 4. Inheritance is still assumed for applied tags and monikers specified in metadata for Group items, EXCEPT if the inheritTags configuration property in the "habot" metadata namespace prevents it (for tags only, metadata monikers are always inherited), like so: ``` Group Kitchen ["object:room"] { habot="Cuisine" [ inheritTags=false ] } ``` 5. "habot:" prefixed tags will move gradually to the "habot" item metadata namespace. Signed-off-by: Yannick Schaus <[email protected]>
- Loading branch information
Showing
21 changed files
with
694 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/main/java/org/openhab/ui/habot/nlp/ItemNamedAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/** | ||
* Copyright (c) 2010-2018 by the respective copyright holders. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.openhab.ui.habot.nlp; | ||
|
||
public class ItemNamedAttribute { | ||
public enum AttributeSource { | ||
TAG, | ||
METADATA | ||
} | ||
|
||
public ItemNamedAttribute(String type, String value, boolean inherited, AttributeSource source) { | ||
super(); | ||
this.type = type; | ||
this.value = value; | ||
this.inherited = inherited; | ||
this.source = source; | ||
} | ||
|
||
String type; | ||
String value; | ||
boolean inherited; | ||
AttributeSource source; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
public boolean isInherited() { | ||
return inherited; | ||
} | ||
|
||
public void setInherited(boolean inherited) { | ||
this.inherited = inherited; | ||
} | ||
|
||
public AttributeSource getSource() { | ||
return source; | ||
} | ||
|
||
public void setSource(AttributeSource source) { | ||
this.source = source; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + (inherited ? 1231 : 1237); | ||
result = prime * result + ((source == null) ? 0 : source.hashCode()); | ||
result = prime * result + ((type == null) ? 0 : type.hashCode()); | ||
result = prime * result + ((value == null) ? 0 : value.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
ItemNamedAttribute other = (ItemNamedAttribute) obj; | ||
// doesn't matter | ||
// if (inherited != other.inherited) { | ||
// return false; | ||
// } | ||
// if (source != other.source) { | ||
// return false; | ||
// } | ||
if (type == null) { | ||
if (other.type != null) { | ||
return false; | ||
} | ||
} else if (!type.equals(other.type)) { | ||
return false; | ||
} | ||
if (value == null) { | ||
if (other.value != null) { | ||
return false; | ||
} | ||
} else if (!value.equals(other.value)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.