Exemplo n.º 1
0
def _trainTimex(timexFeatures, timexLabels, grid=False):
    """
    Purpose: Train a classifer for Timex3 expressions

    @param tokenVectors: A list of tokens represented as feature dictionaries
    @param Y: A list of lists of Timex3 classifications for each token in each sentence
    """

    assert len(timexFeatures) == len(timexLabels), "{} != {}".format(len(timexFeatures), len(timexLabels))

    Y = [l["entity_label"] for l in timexLabels]

    clf, vec = train_classifier(timexFeatures, Y, do_grid=grid, ovo=True)
    return clf, vec
Exemplo n.º 2
0
def _trainEventClass(eventClassFeatures, eventClassLabels, grid=False):
    """
    Model::_trainEventClass()

    Purpose: Train a classifer for event class identification

    @param tokenVectors: A list of tokens represented as feature dictionaries
    @param Y: A list of lists of event classifications for each token, with one list per sentence
    """

    assert len(eventClassFeatures) == len(eventClassLabels), "{} != {}".format(len(eventClassFeatures), len(eventClassLabels))

    Y = [l["entity_label"] for l in eventClassLabels]

    clf, vec = train_classifier(eventClassFeatures, Y, do_grid=grid)
    return clf, vec
Exemplo n.º 3
0
def _trainTlink(tokenVectors, Y, grid=False):
    """
    Model::_trainRelation()

    Purpose: Train a classifer for temporal relations between events and timex3 labels

    @param tokenVectors: A list of tokens represented as feature dictionaries
    @param Y: A list of relation classifications for each pair of timexes and events.
    """

    print len(tokenVectors)
    print len(Y)

    assert len(tokenVectors) == len(Y)

    clf, vec = train_classifier(tokenVectors, Y, do_grid=grid, ovo=True)
    return clf, vec