Input: A list of documents:
[‘The quick brown fox jumps over the lazy dog’, ‘The quick brown fox jumps over the lazy dog again’, ‘The quick brown fox jumps over the lazy dog again and again’]
Output: documents = [‘The quick brown fox jumps over the lazy dog’, ‘The quick brown fox jumps over the lazy dog again’, ‘The quick brown fox jumps over the lazy dog again and again’]
# Get the words from the documents
words = []
for doc in documents:
words += doc.split()
# Get the unique words
unique_words = set(words)
# Print the number of unique words
print(f’The number of unique words is {len(unique_words)}’)
Prompt: Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Design a Python program to find out the number of unique keywords used in documents.
### Input:
A list of documents:
[‘The quick brown fox jumps over the lazy dog’, ‘The quick brown fox jumps over the lazy dog again’, ‘The quick brown fox jumps over the lazy dog again and again’]
### Output:
documents = [‘The quick brown fox jumps over the lazy dog’, ‘The quick brown fox jumps over the lazy dog again’, ‘The quick brown fox jumps over the lazy dog again and again’]
# Get the words from the documents
words = []
for doc in documents:
words += doc.split()
# Get the unique words
unique_words = set(words)
# Print the number of unique words
print(f’The number of unique words is {len(unique_words)}’)