BERTopic icon indicating copy to clipboard operation
BERTopic copied to clipboard

Punctuation being removed regardless of CountVectorizer regex captures.

Open gavinanderson-fnf opened this issue 3 years ago • 2 comments

Basically, I am trying to keep punctuation, specifically apostrophes and dashes, in the bertopic model. I have tried numerous instances of CountVectorizor token_patten regex expressions including: # vectorizer_model = CountVectorizer(token_pattern=r"(?u)\b[\w'-]+\b", ngram_range=(3,3)) # vectorizer_model = CountVectorizer(token_pattern=r"(?u)\S+", ngram_range=(3,3)) # vectorizer_model = CountVectorizer(token_pattern=r"(?u)\b\w\w+\b|!|'|?|"|'", ngram_range=(3,3)) vectorizer_model = CountVectorizer(token_pattern=r"[^\s]+", ngram_range=(3,3)) Is there another parameter I can modify to remove this punctuation? It seems like something internal might be removing apostrophes and such from the tokens.

gavinanderson-fnf avatar May 11 '23 21:05 gavinanderson-fnf

Could you share your full code? I believe if you are using the default embedding model, it will do some slight preprocessing for you whilst if you use a custom model this should not happen. I think it would be solved with embedding_model="all-MiniLM-L6-v2".

MaartenGr avatar May 15 '23 11:05 MaartenGr

Closing this due to inactivity. Let me know if I need to re-open the issue!

MaartenGr avatar Sep 27 '23 08:09 MaartenGr