-
Notifications
You must be signed in to change notification settings - Fork 23
Coding the State
The State is in a state of development, so this documentation is going to be very minimal.
odinson.state
in reference.conf
contains the config for the state. The StateFactory
(ai.lum.odinson.state.StateFactory) uses
state.provider
to decide what will provide the state. A small list of intended providers is there in the comments. Details
needed by each provider are in their own sections, like state.sql
. The different providers can optimize for different attributes
like speed, persistence, memory usage, etc. and the StateFactory
might switch between them depending on runtime conditions.
Code for the state is located in package ai.lum.odinson.state
. Trait State
provides the very simple outline. Two methods
addResultItems
and getResultItems
are paired. The third getDocIds
is an optimization so that results can be obtained
from individual documents in the likely case that retrieving results from all documents is prohibitively expensive.
States are normally transient and only available during a query. They are created in ExtractorEngine.extractMentions
by a
stateFactory
. The state is included in the query calls so that the state can be queried. The query method temporarily sets
the state of the OdinsonQuery
argument, just before it is used for an odinSearch
. If that argument is a composite of
additional OdinsonQuery
objects, i.e., subqueries, it sets their states as well, recursively. Immediately after the query, the state is
cleared. However, the results of odinSearch
are added to the state so that subsequent queries that are part of the
same extraction process can search the state. The results are of type OdinResults
. They are used in the construction
of an iterator, an OdinResultsIterator
, which is used in State.addResultItems
.
A Mention
can be created from OdinResults
and that is normally what happens at the end of ExtractorEngine.extractMentions
.
These same OdinResults
can be retrieved from the state with State.getResultItems
and used to create Mentions
as if they
had been found somewhere else.