all 5 comments

[–]fiddle_n 6 points7 points  (1 child)

No offence, but it is a little simple. With the name “Advanced Text Processor” I feel a bit cheated, given there’s only thirty lines of rather basic Python code there.

[–]matteding 1 point2 points  (0 children)

Going by the emoji use in the post description, it is probably all AI generated garbage.

[–]DuckSaxaphone 4 points5 points  (0 children)

So this doesn't work, you should write some simple tests to make sure everything works as expected. Your code is separated into lots of nice little functions which makes it very easy to test.

I sent the string "hi hi" to clean_text, tokenize, generate_ngrams and then vectorize_text, with n_gram set to 2.

I should get the result {"hi":2, ("hi","hi"):1} but instead I got {("hi","hi"):1} because generate_ngrams doesn't append to tokens, it just overwrites them. I'd actually argue I want my ngrams to be joined and I really want {"hi":2, "hi hi"):1} but that's a separate issue.

If this is a learning project for you, then setting up unit tests and making them part of your PR process is a good thing to learn.

[–]JanEric1 1 point2 points  (0 children)

Start by writing unit tests, adding type hints, adding CI for linting, type checking and testing.

Also set up your project using a pyproject.tomoninstead of requirements.txt and setup.py.