�
�\�h� �
�� � d Z ddlmZ ddlmZmZ ddlZddlZ ed� Zej � dde
dedee
ef fd �� Zej � de
dee
ef fd
�� Z
ej � de
dee
ef fd�� Zej � de
dee
ef fd�� Zej � dde
d
edee
ef fd�� Zej% d� de
fd�� Zedk( rej+ � yy)un
Text Analyzer MCP Server
AI 에이전트에서 답변 문자열의 글자 수를 체크하는 FastMCP 서버
� )�FastMCP)�Dict�AnyNzText Analyzer Server�text�include_spaces�returnc � � | sddddd�S t | � }t | j dd� � }| j d� }||||||r|n|d�}|S )u�
텍스트의 글자 수를 계산합니다.
Args:
text: 분석할 텍스트
include_spaces: 공백을 포함할지 여부 (기본값: True)
Returns:
Dict containing character count analysis
r )�total_characters�characters_without_spaces�spaces_count�text_length� � )r
r r r
�include_spaces_setting�final_count)�len�replace�count)r r �total_chars�chars_without_spacesr �results �3/Users/leejg/Desktop/mcp/my/text_analyzer_server.py�count_charactersr sr � � � !�)*���
�
� �d�)�K��t�|�|�C��4�5���:�:�c�?�L� (�%9�$�"�"0�&4�{�:N�
�F� �M� c �� � | sdddd�S t j d| j � � }t |� }|rt d� |D � � t |� z nd}t |� t |� t
|d� d�S )u�
텍스트의 단어 수를 계산합니다.
Args:
text: 분석할 텍스트
Returns:
Dict containing word count analysis
r g )�
word_count�unique_words�average_word_lengthz\b\w+\bc 3 �2 K � | ] }t |� �� � y �w)N)r )�.0�words r � <genexpr>zcount_words.<locals>.<genexpr>H s � �� �1�4�S��Y�1�s �� )�re�findall�lower�set�sumr �round)r �wordsr �
avg_lengths r �count_wordsr, 2 s} � � ���#&�
�
�
�J�J�z�4�:�:�<�0�E��u�:�L�BG��1�5�1�1�C��J�>�Q�J� �%�j��L�)�$�Z��3�� r c �� � | s
dddddddd�S dddddddd�}| D ]� }|j � r|dxx dz
cc<