예제 #1
0
def argmax(w, e, loss=0):
    """Function that predicts the Quotation and the Author, given an example.

    Args:
        w: A list of weights
        e: A quotation.Example object
    Returns:
        A list of quotation.Row objects with the prediction.
    """

    tasks = []
    i = 0
    for r in e.x:
        l = 0
        if loss > 0 and not find(r, e.y):
            l = loss

        coref = w * np.array(r.coref.feat)
        t = wis.Task(r.quote.start, r.quote.end, np.sum(coref) + l, i)

        tasks.append(t)
        i += 1

    wmax, set_tasks = wis.schedule(tasks)

    result = convertTasks(set_tasks, e.x)

    return result
예제 #2
0
def argmax(w, e, loss=0):
    """Function that predicts the Quotation and the Author, given an example.

    Args:
        w: A list of weights
        e: A quotation.Example object
    Returns:
        A list of quotation.Row objects with the prediction.
    """

    tasks = []
    i = 0
    for r in e.x:
        l = 0
        if loss > 0 and not find(r, e.y):
            l = loss

        coref = w * np.array(r.coref.feat)
        t = wis.Task(r.quote.start, r.quote.end, np.sum(coref) + l, i)

        tasks.append(t)
        i += 1

    wmax, set_tasks = wis.schedule(tasks)

    result = convertTasks(set_tasks, e.x)

    return result
예제 #3
0
    def test_schedule(self):

        tasks = [Task(0,1,1,0), Task(0,2,1,0), 
                        Task(1,4,1,0), Task(4,5,1,0), Task(2,6,1,0), Task(5,7,1,0)]

        set_correct = [Task(0,1,1,0), Task(1,4,1,0), Task(4,5,1,0), Task(5,7,1,0)]
        max_w, set_tasks = wis.schedule(tasks)

        self.assertEqual(set_correct, set_tasks)