Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memberikan Opsi Stopword Custom dan Menambahkan min_length #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Sastrawi/StopWordRemover/StopWordRemover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ def __init__(self, dictionary):
def get_dictionary(self):
return self.dictionary

def remove(self, text):
def remove(self, text, min_length: int = 1):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keliatannya fitur type hints tidak dikenali di python 2.7 sehingga menyebabkan build error: https://travis-ci.org/har07/PySastrawi/builds/430521968?utm_source=github_status&utm_medium=notification

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bagaimana kalau dihapus saja bagian type hints nya (: int )? Sayang sekali kalau harus drop support untuk python 2.7 karena version 2.7 masih banyak beredar (default di ubuntu < 18.04 dll), termasuk di laptop saya 😸

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup gk masalah sih mas, berarti yg gk bisa di python 2.7 cuma :int nya kan?

"""Remove stop words."""
words = text.split(' ')
stopped_words = [word for word in words if not self.dictionary.contains(word)]
stopped_words = [word for word in words if not self.dictionary.contains(word) and len(word) >= min_length]

return ' '.join(stopped_words)

Expand Down