How to Set Persona/Pattern Card Programmatically in Sitecore?

Recently came across a very interesting requirement of analyzing user’s pattern based on search action performed by user on the site. Every webiste has one common functionality implemented – site search. Here you can hook your code to understand user’s pattern by observing the keywords user is searching. For example: whenever user search terms like software, programming or computer …