コード例 #1
0
    m = np.zeros(shape)

    c = (context[context.doc == d][['line', 'text', 'type']]).drop_duplicates()
    c.set_index('line', inplace=True)

    for i in xrange(shape[0]):
        try:
            slice = c.loc[i, ['text', 'type']]
            rows = slice.values

            if len(rows.shape) == 1:
                rows = [rows]

            for row in rows:
                val, kind = row
                j = lat_voc.encode_fast(val, kind)
                m[i, j] = 1
        except KeyError as e:
            pass

    # Fill in context between the context annotation and the events

    fill_context_events(m, d, context, events)


    # Perform propagation heuristic
    #m = drag_context(m)
    ###############################

    # Fill between events heuristic
    fill_between_events(m, d, context, events)