Created on Oct 5, 2012
@author: georgianadinu
Bases: object
Parent class of the composition models.
Uses a composition model to compose elements.
data: data to be composed. List of tuples, each containing 3 strings: (arg1, arg2, composed_phrase). arg1 and arg2 are the elements to be composed and composed_phrase is the string associated to their composition.
arg_space: argument space(s). Space object or a tuple of two Space objects (e.g. my_space, or (my_space1, my_space2)). If two spaces are provided, arg1 elements of data are interpreted in space1, and arg2 in space2.
List of strings, the column strings of the resulted composed space.
Prints the parameters of the composition model to file.
Prints the parameters of the compositional model in an appropriate format, specific to each model.
TO BE MOVED TO A UTILS MODULE!
String, name of the composition model.
Trains a composition model and sets its learned parameters.
train_data: list of string tuples. Each tuple contains 3 string elements: (arg1, arg2, phrase).
arg_space: argument space(s). Space object or a tuple of two Space objects (e.g. my_space, or (my_space1, my_space2)). If two spaces are provided, arg1 elements of train data are interpreted in space1, and arg2 in space2.
phrase space: phrase space, of type Space.
Calls the specific training routine of the current composition model. Training tuples which contain strings not found in their respective spaces are ignored.
The id2column attribute of the resulted composed space is set to be equal to that of the phrase space given as an input.
TO BE MOVED TO A UTILS MODULE!
Created on Oct 15, 2012
@author: georgianadinu
Bases: composes.composition.composition_model.CompositionModel
Implements the dilation compositional model:
\(\vec{p} = (\vec{u} \cdot \vec{u}) \vec{v} + (\lambda - 1) (\vec{u} \cdot \vec{v}) \vec{u}\)
where \(\vec{p}\) is the vector of the composed phrase, \(\vec{u}, \vec{v}\) the vectors of the components and \(\lambda\) is a scalar.
Created on Oct 5, 2012
@author: georgianadinu
Bases: composes.composition.composition_model.CompositionModel
Implements the full additive compositional model:
\(\vec{p} = A \vec{u} + B \vec{v}\)
where \(\vec{p}\) is the vector of the composed phrase, \(\vec{u}, \vec{v}\), the vectors of the components and \(A\), \(B\) are two matrices.
Transpose of matrix A parameter, of type Matrix.
Transpose of matrix B parameter, of type Matrix.
Regression method to be used in training, of type RegressionLearner. Default is LstsqRegressionLearner.
Created on Oct 11, 2012
@author: georgianadinu
Bases: composes.composition.composition_model.CompositionModel
Implements the lexical function compositional model.
\(\vec{p} = U \vec{v}\)
where \(\vec{p}\) is the vector of the composed phrase, \(U\) is the matrix representation of the first component (the lexical function) and \(\vec{v}\) is the vector representation of the second component
Minimal number of samples for each training instance. Default 3.
Uses a lexical function composition model to compose elements.
data: data to be composed. List of tuples, each containing 3 strings: (function_word, arg, composed_phrase). function_word and arg are the elements to be composed and composed_phrase is the string associated to their composition. function_word elements are interpreted in self.function_space.
arg_space: argument space, of type Space. arg elements of data are interpreted in this space.
Function space parameter, containing the lexical functions, of type Space. Can be set through training or through initialization, default None.
Has intercept parameter, boolean. If True, then the function_space is assumed to contain intercept. Can be set through training or through initialization, default is assumed to be False.
Regression method to be used in training, of type RegressionLearner. Default is RidgeRegressionLearner(param=1).
Trains a lexical function composition model to learn a function space and sets the function_space parameter.
train_data: list of string tuples. Each tuple contains 3 string elements: (function_word, arg, phrase).
arg_space: argument space, of type Space. arg elements of train data are interpreted in this space.
phrase space: phrase space, of type Space. phrase elements of the train data are interpreted in this space.
Training tuples which contain strings not found in their respective spaces are ignored. Function words containing less than _MIN_SAMPLES training instances are ignored. For example, if _MIN_SAMPLES=2 and function word “red” occurs in only one phrase, “red” is ignored.
The id2column attribute of the resulted composed space is set to be equal to that of the phrase space given as an input.
Created on Oct 5, 2012
@author: georgianadinu
Bases: composes.composition.composition_model.CompositionModel
Implements the component-wise multiplication compositional model:
\(\vec{p} = \vec{u} \cdot \vec{v}\)
where \(\vec{p}\) is the vector of the composed phrase and \(\vec{u}, \vec{v}\) are the vectors of the components.
\(\vec{u} \cdot \vec{v} = (u_1v_1,...,u_nv_n)\)
Current multiplicative model cannot be exported, it has no parameters.
Current multiplicative model cannot be trained, it has no parameters.
Created on Oct 5, 2012
@author: georgianadinu
Bases: composes.composition.composition_model.CompositionModel
Implements weighted additive compositional model:
\(\vec{p} = \alpha \vec{u} + \beta \vec{v}\)
where \(\vec{p}\) is the vector of the composed phrase and \(\vec{u}, \vec{v}\) are the vectors of the components
When \(\alpha=\beta=0.5\) the model performs simple vector addition.
Alpha parameter, default 0.5.
Beta parameter, default 0.5.