A keyword is a word or short phrase used to represent a topic, property, emotion, or information need in text. In review analysis, keywords turn a large reading task into a focused search for patterns such as delivery problems or positive opinions. section 5.5.2
Finding delivery problems
Suppose a restaurant chain wants to detect complaints about delivery timeliness. Useful starting keywords include “late delivery,” “long wait,” and “slow service.” Broader terms such as “cold food,” “soggy fries,” and “starving” may reveal related service failures that a narrow list would miss. section 5.5.2
Treat a generated keyword list as a starting point rather than a complete answer:
- Check whether the terms match the business question and the language of the records. section 5.5.2
- Look for missing terminology caused by changing language, market shifts, personal assumptions, or narrow framing. section 5.5.2
- Inspect surrounding context and account for inflections, contractions, and other word-form variations before interpreting matches. section 5.5.3
Positive Portuguese reviews
A prompt can request Portuguese keywords indicating positive product opinions and English translations. Results may include “Excelente” (Excellent), “Confiável” (Reliable), “Rápido” (Fast), “Recomendo” (Recommend), and “Vale a pena” (Worth it). section 5.5.3
Listing 5.5 Generating keywords via ChatGPT API
from openai import OpenAI
def generate_keywords(temperature=0.5, max_tokens=150):
client = OpenAI(
api_key="your_api_key", # Make sure to use your actual API key here
)
prompt = """Generate a list of 20 keywords indicating positive
sentiment to be used for searching customer reviews in Portuguese."""
try:
response = client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model="gpt-4-0125-preview", # Replace with the model you have
access to
temperature=temperature,
max_tokens=max_tokens,
)
return(response.choices[0].message.content.split("\n"))
except Exception as e:
print(f"An error occurred: {str(e)}")
# Example usage
print("Generated Keywords:")
print(generate_keywords())
A Python function sends a keyword-generation prompt through the OpenAI ChatGPT API, controls temperature and token limits, and returns one result per line. section 5.5.3


