Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def extract_features(sentence, template):
return sent2features(sentence, template)
def extract_features(sentence, template):
return sent2features(sentence, template)
template2 = [
"T[-2].lower", "T[-1].lower", "T[0].lower", "T[1].lower",
"T[2].lower",
"T[0].istitle", "T[-1].istitle", "T[1].istitle", "T[-2].istitle",
"T[2].istitle",
# word unigram and bigram
"T[-2]", "T[-1]", "T[0]", "T[1]", "T[2]",
"T[-2,-1]", "T[-1,0]", "T[0,1]", "T[1,2]",
# pos unigram and bigram
"T[-2][1]", "T[-1][1]", "T[0][1]", "T[1][1]", "T[2][1]",
"T[-2,-1][1]", "T[-1,0][1]", "T[0,1][1]", "T[1,2][1]",
# ner
"T[-3][3]", "T[-2][3]", "T[-1][3]",
]
sentence = [(token[0], token[1], token[2], "X") for token in sentence]
return sent2features(sentence, template2)
def transform(sentence):
template = [
"T[-1].isdigit", "T[0].isdigit", "T[1].isdigit",
"T[-1].istitle", "T[0].istitle", "T[1].istitle",
"T[0,1].istitle", "T[0,2].istitle",
"T[-1].is_in_dict", "T[0].is_in_dict", "T[1].is_in_dict",
"T[0,1].is_in_dict", "T[0,2].is_in_dict",
# word unigram and bigram and trigram
"T[-2]", "T[-1]", "T[0]", "T[1]", "T[2]",
"T[-2,-1]", "T[-1,0]", "T[0,1]", "T[1,2]",
"T[-2,0]", "T[-1,1]", "T[0,2]",
# BI tag
"T[-2][1]", "T[-1][1]"
]
sentence = [(token, "X") for token in sentence]
return sent2features(sentence, template)
def transform(sentence):
template = [
"T[-2].lower", "T[-1].lower", "T[0].lower", "T[1].lower", "T[2].lower",
"T[0].istitle", "T[-1].istitle", "T[1].istitle",
# word unigram and bigram
"T[-2]", "T[-1]", "T[0]", "T[1]", "T[2]",
"T[-2,-1]", "T[-1,0]", "T[0,1]", "T[1,2]",
# pos unigram and bigram
"T[-2][1]", "T[-1][1]", "T[0][1]", "T[1][1]", "T[2][1]",
"T[-2,-1][1]", "T[-1,0][1]", "T[0,1][1]", "T[1,2][1]",
# chunk
"T[-3][2]", "T[-2][2]", "T[-1][2]",
]
sentence = [(token[0], token[1], "A") for token in sentence]
return sent2features(sentence, template)
def extract_features(sentence, template):
return sent2features(sentence, template)