Bourdieu API¶
A class for performing Bourdieu analysis on a collection of documents.
This class leverages an embedding model to compute Bourdieu dimensions and topics for the given documents. It supports customization of the analysis through various parameters and the use of generative AI for topic naming.
Source code in bunkatopics/bourdieu/bourdieu_api.py
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 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
__init__(embedding_model, llm=None, bourdieu_query=BourdieuQuery(), topic_param=TopicParam(), topic_gen_param=TopicGenParam(), min_count_terms=2, ranking_terms=20, min_docs_per_cluster=20)
¶
Initializes the BourdieuAPI with the provided models, parameters, and configurations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
llm |
Optional[LLM]
|
The generative AI model for topic naming. |
None
|
embedding_model |
Embeddings
|
The model used for embedding documents. |
required |
bourdieu_query |
BourdieuQuery
|
Configuration for Bourdieu analysis. Defaults to BourdieuQuery(). |
BourdieuQuery()
|
topic_param |
TopicParam
|
Parameters for topic modeling. Defaults to TopicParam(). |
TopicParam()
|
topic_gen_param |
TopicGenParam
|
Parameters for the generative AI in topic naming. Defaults to TopicGenParam(). |
TopicGenParam()
|
min_count_terms |
int
|
Minimum term count for topic modeling. Defaults to 2. |
2
|
Source code in bunkatopics/bourdieu/bourdieu_api.py
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 |
|
fit_transform(docs, terms)
¶
Processes the documents and terms to compute Bourdieu dimensions and topics.
This method applies the embedding model to compute Bourdieu dimensions for each document based on provided queries. It also performs topic modeling on the documents and, if enabled, uses a generative AI model for naming the topics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
docs |
List[Document]
|
List of Document objects representing the documents to be analyzed. |
required |
terms |
List[Term]
|
List of Term objects representing the terms to be used in topic modeling. |
required |
Notes
- The method first resets Bourdieu dimensions for all documents.
- It computes Bourdieu continuums based on the configured left and right words.
- Documents are then filtered based on their position relative to a defined radius in the Bourdieu space.
- Topic modeling is performed on the filtered set of documents.
- If
generative_ai_name
is True, topics are named using the generative AI model.
Source code in bunkatopics/bourdieu/bourdieu_api.py
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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|