Domain API for Python#

class eot.wowool.native.core.domain.Domain#

A Domain object can be loaded from a .dom file that has been built with the compiler object.

english_domain_init_2.py#
from eot.wowool.native.core import Language, Domain
from eot.wowool.annotation import Concept

english = Language("english")
entities = Domain("english-entity")
doc = entities(english("I have a car."))
for concept in Concept.iter(doc):
    print(concept)

A Domain object can also be used to apply rules or lexicons to an existing document object.

english_domain_init.py#
from eot.wowool.native.core import Language, Domain
from eot.wowool.annotation import Concept
from eot.wowool.document import Document

english = Language("english")
vehicle = Domain(source="rule:{ 'car'} = Vehicle;")
doc = vehicle(english(Document("I have a car.")))
for concept in Concept.iter(doc):
    print(concept)

This results in the following output:

C:(  0, 13): Sentence
C:(  9, 12): Vehicle
__init__(name=None, source=None, file=None, annotations=None, cache=True, engine: eot.wowool.native.core.engine.Engine = None, disable_plugin_calls=False)#
Parameters
  • name (str) – The name of your domain you want to load.

  • source – The wowool source code of your domain.

  • file (list[str]) – A filename of the wowool source code of your domain.

  • annotations – The annotations you want to expose.

  • cache (boolean) – If you want to load this domain in the cache of the engine.

  • engine (eot.wowool.native.core.engine.Engine) – The engine that will be used to cache the domain files.

property concepts#

Get the concepts in the given domain

from eot.wowool.native.core import Domain

entity = Domain("english-entity")
print(str(entity))
print(entity.concepts)
Param

domains: a comma separated list of concepts used in the given domain.

Returns

list of the concepts in the given domain.

For example:

[‘Address’, ‘City’, ‘Company’, ‘Country’ ]

property dependencies#

Get the dependencies from this domain. These are other domain names that are required to run this domain.

from eot.wowool.native.core import Domain

entity = Domain("english-entity")
# this one does not have any dependencies, so it will return a empty list.
print(entity.dependencies)
Param

dependencies: list of the dependency used in the given domain.

Returns

list of the dependency in the given domain.

property info#

Get the info in the given domain

from eot.wowool.native.core import Domain

entity = Domain("english-entity")
# this one does not have any dependencies, so it will return a empty list.
print(entity.info)
Param

info: a dict

Returns

dict with different information.

Keys:
  • concepts (list(str)) A list of the concepts used in the domain.

  • lexicons (dict) Information about the size of the lexicons in the domain.

  • rules (int) The number of rules in the lexicon.

  • config (dict) The information listed in the ‘.dom_info’ file

  • config[“annotations”] (dict) A dictionary with the number of entries in the different lexicons.

  • config[‘custom’] : Everything else you have added in the .dom_info file.

  • sdk_version (str) The version of sdk that was used to build the domain.