
    fi@                         d Z ddlZddlZddededej        fdZdd	edefd
Zedk    r1 edd          Z	 e
e	            ed          Z e
e           dS dS )zm
Date: 2024/7/6 14:02
Desc: ownthink-knowledge graph
https://ownthink.com/
https://www.ownthink.com/docs/kg/
    N   人工智能entityword	indicatorreturnc                    d}d| i}t          j        ||          }|                                d         s"t          d           t	          j                    S |dk    r |                                d         d         S |dk    r |                                d         d         S |dk    r6t	          j        |                                d         d         dd	g
          S |dk    r |                                d         d         S dS )a  
    Knowledge Graph interface for financial research
    https://ownthink.com/
    :param word: word in chinese
    :type word: str
    :param indicator: entity or desc or avp or tag
    :type indicator: str
    :return: indicator data
    :rtype: list or dict or pandas.DataFrame
    z%https://api.ownthink.com/kg/knowledger   )datar	   z<Can not find the resource, please type into the correct worddescavpu   字段u   值)columnstagN)requestspostjsonprintpd	DataFrame)r   r   urlpayloadrs        D/usr/local/lib/python3.11/dist-packages/akshare/nlp/nlp_interface.pynlp_ownthinkr      s    2C$G 	c(((A6688F LMMM|~~Hvvxx))Fvvxx''E|AFFHHV,U3h=NOOOOEvvxx&&     questionc                     d}d| i}t          j        ||          }|                                }|d         d         d         }|S )u   
    智能问答
    https://ownthink.com/robot.html
    :param question: word in chinese
    :type question: str
    :return: indicator data
    :rtype: list or dict or pandas.DataFrame
    zhttps://api.ownthink.com/botspoken)paramsr	   infotext)r   getr   )r   r   r   r   	json_dataanswers         r   
nlp_answerr#   +   sM     )C!FS(((AIvv&v.FMr   __main__)r   r   u   姚明的身高)r   )r   r   )r   )__doc__pandasr   r   strr   r   r#   __name__nlp_ownthink_dfr   nlp_answer_df r   r   <module>r,      s         ' 's ' '2< ' ' ' ':  #    " z"l(KKKO	E/J(9:::M	E- r   