Open maryjess opened 1 month ago
import nltk import re # Sample receipt text text = """ Walmart Date: 01/09/2024 Milk: $3.00 Bread: $2.50 Eggs: $1.75 Total: $7.25 """ # Tokenize text tokens = nltk.word_tokenize(text) # Use regex to find items and prices pattern = re.compile(r'([A-Za-z]+):\s\$(\d+\.\d{2})') matches = pattern.findall(text) # Extract data items = [{'item': match[0], 'price': float(match[1])} for match in matches] print(items)
Choices:
fetch
Resolves #4
How?
NLTK
Choices:
fetch
Resolves #4