Last active
September 22, 2022 14:13
-
-
Save dtrizna/ac3e6272acd37c4c46b48b039d38b577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from nltk.tokenize import WordPunctTokenizer | |
from sklearn.feature_extraction.text import HashingVectorizer | |
wpt = WordPunctTokenizer() | |
hvwpt = HashingVectorizer( | |
preprocessor=lambda x: re.sub(r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}", "_IPADDRESS_", x), | |
tokenizer=wpt.tokenize, | |
token_pattern=None, | |
lowercase=False, | |
ngram_range=(1,2), | |
n_features=2**18 | |
) | |
X = {} | |
X["HashingVectorizer"] = hvwpt.fit_transform(raw_commands) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment