|
108 | 108 | " return pd.DataFrame([r.values() for r in records], columns=keys)" |
109 | 109 | ] |
110 | 110 | }, |
| 111 | + { |
| 112 | + "cell_type": "code", |
| 113 | + "execution_count": null, |
| 114 | + "id": "bd1d9775", |
| 115 | + "metadata": {}, |
| 116 | + "outputs": [], |
| 117 | + "source": [ |
| 118 | + "def query_first_non_empty_cypher_to_data_frame(*filenames : str, parameters: typ.Optional[typ.Dict[str, typ.Any]] = None):\n", |
| 119 | + " \"\"\"\n", |
| 120 | + " Executes the Cypher queries of the given files and returns the first result that is not empty.\n", |
| 121 | + " If all given file names result in empty results, the last (empty) result will be returned.\n", |
| 122 | + " By additionally specifying \"limit=\" the \"LIMIT\" keyword will appended to query so that only the first results get returned.\n", |
| 123 | + " \"\"\"\n", |
| 124 | + " result=pd.DataFrame()\n", |
| 125 | + " for filename in filenames:\n", |
| 126 | + " result=query_cypher_to_data_frame(filename, parameters)\n", |
| 127 | + " if not result.empty:\n", |
| 128 | + " print(\"The results have been provided by the query filename: \" + filename)\n", |
| 129 | + " return result\n", |
| 130 | + " return result" |
| 131 | + ] |
| 132 | + }, |
111 | 133 | { |
112 | 134 | "cell_type": "code", |
113 | 135 | "execution_count": null, |
|
177 | 199 | " empty_result = pd.DataFrame(columns=[\"codeUnitName\", 'projectName', 'communityId', 'centrality', 'embedding'])\n", |
178 | 200 | " return empty_result\n", |
179 | 201 | "\n", |
180 | | - " embeddings = query_cypher_to_data_frame(cypher_file_name, parameters)\n", |
| 202 | + " existing_embeddings_query_filename=\"../cypher/Node_Embeddings/Node_Embeddings_0a_Query_Calculated.cypher\"\n", |
| 203 | + " embeddings = query_first_non_empty_cypher_to_data_frame(existing_embeddings_query_filename, cypher_file_name, parameters=parameters)\n", |
181 | 204 | " display(embeddings.head()) # Display the first entries of the table\n", |
182 | 205 | " return embeddings" |
183 | 206 | ] |
|
210 | 233 | " # and the code unit and artifact name of the query above as preparation for the plot\n", |
211 | 234 | " node_embeddings_for_visualization = pd.DataFrame(data = {\n", |
212 | 235 | " \"codeUnit\": embeddings.codeUnitName,\n", |
213 | | - " \"artifact\": embeddings.artifactName,\n", |
| 236 | + " \"artifact\": embeddings.projectName,\n", |
214 | 237 | " \"communityId\": embeddings.communityId,\n", |
215 | 238 | " \"centrality\": embeddings.centrality,\n", |
216 | 239 | " \"x\": [value[0] for value in two_dimension_node_embeddings],\n", |
|
316 | 339 | " \"dependencies_projection\": \"java-package-embeddings-notebook\",\n", |
317 | 340 | " \"dependencies_projection_node\": \"Package\",\n", |
318 | 341 | " \"dependencies_projection_weight_property\": \"weight25PercentInterfaces\",\n", |
319 | | - " \"dependencies_projection_embedding_dimension\":\"64\" \n", |
| 342 | + " \"dependencies_projection_write_property\": \"embeddingsFastRandomProjection\",\n", |
| 343 | + " \"dependencies_projection_embedding_dimension\":\"64\"\n", |
320 | 344 | "}\n", |
321 | 345 | "embeddings = create_node_embeddings(\"../cypher/Node_Embeddings/Node_Embeddings_1d_Fast_Random_Projection_Stream.cypher\", java_package_embeddings_parameters)\n" |
322 | 346 | ] |
|
396 | 420 | " \"dependencies_projection\": \"typescript-module-embeddings-notebook\",\n", |
397 | 421 | " \"dependencies_projection_node\": \"Module\",\n", |
398 | 422 | " \"dependencies_projection_weight_property\": \"lowCouplingElement25PercentWeight\",\n", |
| 423 | + " \"dependencies_projection_write_property\": \"embeddingsFastRandomProjection\",\n", |
399 | 424 | " \"dependencies_projection_embedding_dimension\":\"64\" \n", |
400 | 425 | "}\n", |
401 | 426 | "embeddings = create_node_embeddings(\"../cypher/Node_Embeddings/Node_Embeddings_1d_Fast_Random_Projection_Stream.cypher\", typescript_module_embeddings_parameters)\n" |
|
0 commit comments