コード例 #1
0
def test_model_extracts_nickname_symbol_filter(
        model: DefinitionDetectionModel):
    prediction_type = "DocDef2"
    features = model.featurize("The agent acts with SYMBOL SYMBOL")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0] == 0
    assert slots[prediction_type][0] == ["O", "O", "O", "O", "O", "O"]
コード例 #2
0
def test_model_extracts_simple_definitions(model: DefinitionDetectionModel):
    prediction_type = "W00"
    features = model.featurize("Neural networks are machine learning models.")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "TERM", "TERM", "O", "DEF", "DEF", "DEF", "O"
    ]
コード例 #3
0
def test_model_extracts_nickname_symbol_separated_by_colon(
    model: DefinitionDetectionModel, ):
    prediction_type = "DocDef2"
    features = model.featurize("The agent acts with a policy : SYMBOL")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O", "O", "O", "O", "O", "DEF", "O", "TERM"
    ]
コード例 #4
0
def test_model_extracts_nickname_symbol_parentheses(
        model: DefinitionDetectionModel):
    prediction_type = "DocDef2"
    features = model.featurize("The agent acts with policy (SYMBOL)")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O", "O", "O", "O", "DEF", "O", "TERM", "O"
    ]
コード例 #5
0
def test_model_extract_abbreviation_shortened_word(
        model: DefinitionDetectionModel):
    prediction_type = "AI2020"
    features = model.featurize("We propose Conductive Networks (CondNets)")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O", "O", "DEF", "DEF", "O", "TERM", "O"
    ]
コード例 #6
0
def test_model_extracts_nickname_for_th_index_pattern(
        model: DefinitionDetectionModel):
    prediction_type = "DocDef2"
    features = model.featurize(
        "This process repeats for every SYMBOLth timestep")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O", "O", "O", "O", "O", "TERM", "DEF"
    ]
コード例 #7
0
def test_model_extract_abbreviation_acronym(model: DefinitionDetectionModel):
    prediction_type = "AI2020"
    features = model.featurize(
        "We use a Convolutional Neural Network (CNN) based architecture")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O",
        "O",
        "O",
        "DEF",
        "DEF",
        "DEF",
        "O",
        "TERM",
        "O",
        "O",
        "O",
    ]
コード例 #8
0
def test_model_extracts_nickname_before_symbol(
        model: DefinitionDetectionModel):
    prediction_type = "DocDef2"
    features = model.featurize(
        "The agent acts with a policy SYMBOL in each timestep SYMBOL")
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O",
        "O",
        "O",
        "O",
        "O",
        "DEF",
        "TERM",
        "O",
        "O",
        "DEF",
        "TERM",
    ]
コード例 #9
0
def test_model_extracts_nickname_after_symbol(model: DefinitionDetectionModel):
    prediction_type = "DocDef2"
    features = model.featurize(
        "The architecture consists of SYMBOL dense layers trained with SYMBOL learning rate"
    )
    intents, slots, _ = model.predict_batch([features], prediction_type)
    assert intents[prediction_type][0]
    assert slots[prediction_type][0] == [
        "O",
        "O",
        "O",
        "O",
        "TERM",
        "DEF",
        "DEF",
        "O",
        "O",
        "TERM",
        "DEF",
        "DEF",
    ]
コード例 #10
0
def model():
    model = DefinitionDetectionModel(["AI2020", "DocDef2", "W00"])
    return model
コード例 #11
0
def model():
    model = DefinitionDetectionModel()
    return model
コード例 #12
0
def model():
    model = DefinitionDetectionModel("DocDef2+AI2020+W00")
    return model