Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saimadhu-polamuri/fb850e5a4d900523417d04e4ede5a07f to your computer and use it in GitHub Desktop.
Save saimadhu-polamuri/fb850e5a4d900523417d04e4ede5a07f to your computer and use it in GitHub Desktop.
Create space textcategorizer model
######## Main method ########
def main():
# Load dataset
data = pd.read_csv(data_path)
observations = len(data.index)
print("Dataset Size: {}".format(observations))
# Create an empty spacy model
nlp = spacy.blank("en")
# Create the TextCategorizer with exclusive classes and "bow" architecture
text_cat = nlp.create_pipe(
"textcat",
config={
"exclusive_classes": True,
"architecture": "bow"})
# Adding the TextCategorizer to the created empty model
nlp.add_pipe(text_cat)
# Add labels to text classifier
text_cat.add_label("ham")
text_cat.add_label("spam")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment