File size: 789 Bytes
742b2a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class InputHandler:
    def process_query(self, query):
        """
        Process and validate user input
        """
        # Clean and normalize query
        cleaned_query = query.strip()
        
        # Add context if needed
        if len(cleaned_query) < 5:
            raise ValueError("Query too short. Please provide more details.")
            
        return cleaned_query
    
    def extract_keywords(self, query):
        """
        Extract important keywords from query
        """
        # Simple keyword extraction (could be enhanced with NLP)
        stop_words = {'the', 'is', 'at', 'which', 'on', 'in', 'for', 'of', 'with', 'by'}
        words = query.lower().split()
        keywords = [word for word in words if word not in stop_words]
        return keywords