Skip to content

Can´t use Extension attributes in Tok2Vec #6527

Discussion options

You must be logged in to vote

@adrianeboyd I just did this, created a custom feature extractor, and it is working great.
For future users, here is the Custom feature extractor code:

def forward(
    model: Model[List[Doc], List[Ints2d]], docs, is_train: bool
) -> Tuple[List[Ints2d], Callable]:
    columns = model.attrs["columns"]
    possible_extra_columns = ["IS_BOLD", "IS_ITALIC"]
    extra_columns = [x for x in columns if x in possible_extra_columns]
    columns = [x for x in columns if x not in possible_extra_columns]
    features: List[Ints2d] = []
    for doc in docs:
        if hasattr(doc, "to_array"):
            attrs = doc.to_array(columns)
        else:
            attrs = doc.doc.to_array(columns)[doc.sta…

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@marcuscollins
Comment options

Answer selected by svlandeg
Comment options

You must be logged in to vote
2 replies
@beatanyari
Comment options

@adrianeboyd
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat / tok2vec Feature: Token-to-vector layer and pretraining
6 participants
Converted from issue

This discussion was converted from issue #6527 on December 10, 2020 14:38.