Skip to main content
Glama

MCP Starter for Puch AI

by Kulraj69
parsing.cpython-311.pyc8.81 kB
� ���h"� �|�ddlZddlZddlmZmZmZmZmZddlm Z hd�Z hd�Z de deee effd�Z de d ee deee effd �Zde d e dee effd �Zd eee efdeee effd�Zd eee efdee fd�Zdde dedee fd�ZdS)�N)�List�Dict�Any�Set�Optional)�Counter>�top�best�easy�fast�good�great�robust�simple�leading�premium�complete�powerful�reliable� efficient� excellent� intuitive� affordable� recommended� comprehensive>�bad�poor�slow�weak�basic�buggy�limited�outdated� confusing� difficult� expensive� incomplete� overpriced� unreliable� complicated� frustrating� problematic� raw_answer�returnc��d}d}t��}tj||��}|D]R} tj|��}|jr-|jr&|j�d|j��}|�|���L#Y�PxYwtj||��}|D]R} tj|��}|jr-|jr&|j�d|j��} |�| ���L#Y�PxYwt��} |D]F}ttjtj |��|tj ����} | | |<�Gd�| � ��D��S)z:Extract domains from raw answer using regex and tldextractzhttps?://[^\s<>"{}|\\^`\[\]]+zD\b(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}\b�.c��g|] \}}||d��� S))�domain�count�)�.0r2r3s �E/Users/kulraj/agent09/mcp-starter/mcp-bearer-token/../data/parsing.py� <listcomp>z#extract_domains.<locals>.<listcomp>7s$�� `� `� `�=�6�5�v�� .� .� `� `� `�) �set�re�findall� tldextract�extractr2�suffix�addr�len�escape� IGNORECASE� most_common) r-� url_pattern�domain_pattern�domains�urls�url� extractedr2�standalone_domains� clean_domain� domain_countsr3s r6�extract_domainsrMs���3�K�\�N��e�e�G� �:�k�:� .� .�D����� �"�*�3�/�/�I��� $�I�$4� $�%�,�A�A�y�/?�A�A��� � �F�#�#�#��� � �H������N�J�?�?��$���� �"�*�6�2�2�I��� *�I�$4� *�"+�"2�G�G�Y�5E�G�G� �� � �L�)�)�)��� � �H�����I�I�M��&�&���B�J�r�y��0�0�*�b�m�L�L�M�M�� %� �f��� `� `�M�D]�D]�D_�D_� `� `� `�`s�AA6�6A:�AC � C$� brand_setc�p�g}|D]�}tjtj|��tj��}t |�|����}|rB|d���}t|��}|�|||d�����|� d����|S)z1Extract brand mentions with count and first indexr)�brandr3� first_indexc��|dS�NrQr4��xs r6�<lambda>z"extract_mentions.<locals>.<lambda>Ls ���-� 0�r8��key) r:�compilerArB�list�finditer�startr@�append�sort)r-rN�mentionsrP�pattern�matchesrQr3s r6�extract_mentionsrb9s����H�� � ���*�R�Y�u�-�-�r�}�=�=���w�'�'� �3�3�4�4�� � �!�!�*�*�*�,�,�K���L�L�E� �O�O���*��� � � �� �M�M�0�0�M�1�1�1� �Or8rPc���d}d}d}tjtj|��tj��}t |�|����}|D]�}t d|���dz ��}tt|��|� ��dz��} ||| �� ���t�fd�tD����} t�fd�tD����} || z }|| z }|dz }��|dkrdddd�S|||zdzz } |||zdzz } d| z | z }t| d ��tt d|��d ��t| d ��d�S) z:Compute sentiment scores for a brand using keyword windowsr�(c3�$�K�|] }|�v�dV�� dS��Nr4�r5�word�contexts �r6� <genexpr>z"naive_sentiment.<locals>.<genexpr>_�'�����O�O�T�t�w���q�����O�Or8c3�$�K�|] }|�v�dV�� dSrfr4rhs �r6rkz"naive_sentiment.<locals>.<genexpr>`rlr8rggg�?)�positive�neutral�negative�)r:rYrArBrZr[�maxr\�minr@�end�lower�sum�POSITIVE_WORDS�NEGATIVE_WORDS�round)r-rP�positive_count�negative_count�total_contextsr`ra�matchr\rt�context_positive�context_negative�positive_ratio�negative_ratio� neutral_ratiorjs @r6�naive_sentimentr�Os�����N��N��N��j���5�)�)�2�=�9�9�G��7�#�#�J�/�/�0�0�G�� � ���A�u�{�{�}�}�r�)�*�*���#�j�/�/�5�9�9�;�;��#3�4�4���U�3�Y�'�-�-�/�/���O�O�O�O�^�O�O�O�O�O���O�O�O�O�^�O�O�O�O�O���*�*���*�*���!���������C�S�A�A�A�$�~��'F��'J�K�N�#�~��'F��'J�K�N��.�(�>�9�M��.�!�,�,���Q� �.�.��2�2��.�!�,�,� � �r8r_c��|sgStd�|D����}g}|D]:}|d|z }|�|dt|d��id����;|S)z$Compute share of voice from mentionsc3�&K�|] }|dV�� dS)r3Nr4)r5�ms r6rkzcompute_sov.<locals>.<genexpr>ys&����6�6���7��6�6�6�6�6�6r8r3rPrq)rP�overall� by_platform)rvr]ry)r_�total_mentions�sov_data�mention� brand_sovs r6� compute_sovr�ts��� ��� ��6�6�X�6�6�6�6�6�N��H�� � ���G�$�~�5� �����W�%��Y��*�*�� � � � � � � �Or8c�J�|sdSt|d����}|ddS)z&Find brand with earliest first mentionNc��|dSrSr4rTs r6rVz(compute_first_position.<locals>.<lambda>�s ��Q�}�5E�r8rWrrP)�sorted)r_�sorted_mentionss r6�compute_first_positionr��s7�� ���t��X�+E�+E�F�F�F�O� �1� �g� &�&r8� � max_brandsc���tjd|��}hd���fd�|D��}t|��}d�|�|��D��S)z7Auto-detect brands as Proper Nouns (A-Z leading tokens)z\b[A-Z][a-zA-Z0-9]*\b>�He�It�Or�We�And�But�For�How�Its�Our�She�The�Who�Why�You�From�That�They�This�What�When�With�Your�About�Their�These�Those�Where�Whichc�B��g|]}|�v�t|��dk�|��S)�)r@)r5ri� common_wordss �r6r7z&auto_detect_brands.<locals>.<listcomp>�s:������� �|� #� #��D� � �A� � � �(5� � r8c��g|]\}}|��Sr4r4)r5rPr3s r6r7z&auto_detect_brands.<locals>.<listcomp>�s�� K� K� K�l�e�U�E� K� K� Kr8)r:r;rrC)r-r��words�potential_brands� brand_countsr�s @r6�auto_detect_brandsr��s���� �J�/�� <� <�E����L� ��������� �+�,�,�L� K� K�l�&>�&>�z�&J�&J� K� K� K�Kr8)r�)r:r<�typingrrrrr� collectionsrrwrx�strrMrb�floatr�r�r��intr�r4r8r6�<module>r�s��� � � � �����1�1�1�1�1�1�1�1�1�1�1�1�1�1����������� ���� $a��$a��T�#�s�(�^�(<�$a�$a�$a�$a�L����S���d�4��S��>�>R�����,#��#�C�#�D��e��4D�#�#�#�#�J�$�t�C��H�~�.��4��S�#�X��3G�����$'�T�$�s�C�x�.�%9�'�h�s�m�'�'�'�'�L�L�3�L�C�L��c��L�L�L�L�L�Lr8

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Kulraj69/mcp-llm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server