Modules
            load_likes(data_directory)
¶
    Load 'like' data from JavaScript files in a given directory.
This function searches for files matching the pattern 'like*.js' within the specified data directory, extracts JSON data from each file, and aggregates the 'like' data into a list.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data_directory | str | The path to the directory containing the 'like*.js' files. | required | 
Returns:
| Type | Description | 
|---|---|
| list[dict[str, LikeInfo]] | list[dict[str, LikeInfo]]: A list of dictionaries containing 'like' information. | 
Raises:
| Type | Description | 
|---|---|
| Exception | If there is an error processing any of the files, the exception is caught, an error message is printed, and the function continues processing remaining files. | 
Source code in search_x_likes/list_likes_in_archive.py
              | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |  | 
            get_embedding(client, text, model='text-embedding-ada-002')
¶
    Generate embedding vectors for a text using the specified OpenAI model.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| client | openAI | An OpenAI client object | required | 
| text | str] | A string containing input text for which to generate embeddings. | required | 
| model | str | The name of the embedding model to use. | 'text-embedding-ada-002' | 
Returns:
| Type | Description | 
|---|---|
| list[float] | list[float]: A list of float representing an embedding vector. | 
Source code in search_x_likes/embed_posts.py
              | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |  | 
            InputApp
¶
    
              Bases: App
Source code in search_x_likes/exact_search.py
                | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |  | 
            compose()
¶
    Set up the layout.
Source code in search_x_likes/exact_search.py
              | 46 47 48 49 50 51 52 53 54 |  | 
            on_input_changed(event)
¶
    Handle input change events.
Source code in search_x_likes/exact_search.py
              | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |  | 
            highlight_query(text, query)
¶
    Wraps every occurrence of the query string in bold Markdown in the text.
Source code in search_x_likes/exact_search.py
              | 22 23 24 25 26 27 28 29 30 |  | 
            InputApp
¶
    
              Bases: App
Source code in search_x_likes/bm25_search.py
                | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |  | 
            compose()
¶
    Set up the layout.
Source code in search_x_likes/bm25_search.py
              | 36 37 38 39 40 41 42 43 44 |  | 
            on_input_changed(event)
¶
    Handle input change events.
Source code in search_x_likes/bm25_search.py
              | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |  | 
            InputApp
¶
    
              Bases: App
Source code in search_x_likes/cosine_search.py
                | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |  | 
            compose()
¶
    Set up the layout.
Source code in search_x_likes/cosine_search.py
              | 66 67 68 69 70 71 72 73 74 |  | 
            on_input_submitted(event)
¶
    Handle input submission events (when Enter is pressed).
Source code in search_x_likes/cosine_search.py
              | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |  | 
            get_top_k_embeddings(df, embeddings_col, search_embedding, k)
¶
    Retrieves the top-k most similar embeddings from a DataFrame.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| df | DataFrame | DataFrame containing the embeddings. | required | 
| embeddings_col | str | Column name of embeddings. | required | 
| search_embedding | ndarray | The embedding of the search string. | required | 
| k | int | Number of top embeddings to retrieve. | required | 
Returns:
| Type | Description | 
|---|---|
| DataFrame | raise EmbeddingColumnTypeError(embeddings_col) | 
Source code in search_x_likes/cosine_search.py
              | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |  |