Skip to content

Commit

Permalink
Create natural_language_processing.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Nov 26, 2024
1 parent 71b97d9 commit a22147a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions QuantumNexusProtocol/src/ai/natural_language_processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords

class NaturalLanguageProcessor:
def __init__(self, text):
self.text = text
nltk.download('punkt')
nltk.download('stopwords')
self.stop_words = set(stopwords.words('english'))

def process(self):
tokens = word_tokenize(self.text)
filtered_tokens = [word for word in tokens if word.lower() not in self.stop_words]
return filtered_tokens

# Example usage
if __name__ == "__main__":
text = "This is an example sentence for natural language processing."
processor = NaturalLanguageProcessor(text)
processed_text = processor.process()
print("Processed Text:", processed_text)

0 comments on commit a22147a

Please sign in to comment.