
    [g\
                     T    S SK Jr  S SKJr  S SKJr  S SKJr  S SK	J
r
  S	S jr S
S jrg)    )	languages)Builder)stemmer)trimmer)stop_word_filterNc                    U=(       d    [        U5      nUR                  U 5        U H=  n[        U[        5      (       a  UR                  " S0 UD6  M,  UR	                  U5        M?     U HG  n[        U[
        [        45      (       a  UR                  US   US   S9  M6  UR                  U5        MI     UR                  5       $ )a  A convenience function to configure and construct a lunr.Index.

Args:
    ref (str): The key in the documents to be used a the reference.
    fields (list): A list of strings defining fields in the documents to
        index. Optionally a list of dictionaries with three keys:
        `field_name` defining the document's field, `boost` an integer
        defining a boost to be applied to the field, and `extractor`
        a callable taking the document as a single argument and returning
        a string located in the document in a particular way.
    documents (list): The list of dictonaries representing the documents
        to index. Optionally a 2-tuple of dicts, the first one being
        the document and the second the associated attributes to it.
    languages (str or list, optional): The languages to use if using
        NLTK language support, ignored if NLTK is not available.

Returns:
    Index: The populated Index ready to search against.
r      )
attributes )	get_default_builderref
isinstancedictfieldtuplelistaddbuild)r   fields	documentsr   builderr   documents          +/usr/lib/python3/dist-packages/lunr/lunr.pylunrr      s    ( 7,Y7GKKeT""MM"E"MM% 	  h..KKK<KK!	  ==?    c           	      <   U b  [         R                  (       a  [        U [        5      (       a  U /n [	        U 5      [	        [         R
                  5      -
  nU(       aU  [        SR                  SR                  U5      SR                  [         R
                  R                  5       5      5      5      e[         R                  " U 5      nU$ [        5       nUR                  R                  [        [        [         5        UR"                  R                  [         5        U$ )zeCreates a new pre-configured instance of Builder.

Useful as a starting point to tweak the defaults.
zEThe specified languages {} are not supported, please choose one of {}z, )langLANGUAGE_SUPPORTr   strsetSUPPORTED_LANGUAGESRuntimeErrorformatjoinkeysget_nltk_builderr   pipeliner   r   r   r   search_pipeline)r   unsupported_languagesr   s      r   r   r   -   s    
 !6!6i%%"I #IT5M5M1N N **0&II34IId66;;=>+  ''	2 N	 )W&6@##G,Nr   )NN)N)r   r   r   lunr.builderr   lunr.stemmerr   lunr.trimmerr   lunr.stop_word_filterr   r   r   r   r   <module>r.      s    "       2"Jr   