Skip to content

Commit 072e978

Browse files
committed
Updated Java translation, code summarization, and test generation examples
Signed-off-by: Saurabh Sinha <[email protected]>
1 parent 6036748 commit 072e978

File tree

3 files changed

+130
-118
lines changed

3 files changed

+130
-118
lines changed

docs/examples/java/notebook/code_summarization.ipynb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
},
312312
"outputs": [],
313313
"source": [
314-
"# Create an analysis object over the java application\n",
314+
"# Create an analysis object for the Java application\n",
315315
"analysis = cldk.analysis(project_path=\"/tmp/commons-cli-rel-commons-cli-1.7.0\", analysis_level=AnalysisLevel.symbol_table)"
316316
]
317317
},
@@ -356,7 +356,7 @@
356356
},
357357
"outputs": [],
358358
"source": [
359-
"# For simplicity, we run the code summarization for a single class and method (this filter can be removed to run this code over the entire application)\n",
359+
"# For simplicity, we run the code summarization on a single class and method (this filter can be removed to run this code over the entire application)\n",
360360
"target_class = \"org.apache.commons.cli.GnuParser\"\n",
361361
"target_method = \"flatten(Options, String[], boolean)\"\n",
362362
"\n",
@@ -366,7 +366,7 @@
366366
" class_file_path = analysis.get_java_file(qualified_class_name=class_name)\n",
367367
"\n",
368368
" # Read code for the class\n",
369-
" with open(class_file_path, 'r') as f:\n",
369+
" with open(class_file_path, \"r\") as f:\n",
370370
" code_body = f.read()\n",
371371
"\n",
372372
" # Initialize treesitter utils for the class file content\n",
@@ -387,17 +387,15 @@
387387
" instruction = format_inst(\n",
388388
" code=sanitized_class,\n",
389389
" focal_method=method_details.declaration,\n",
390-
" focal_class=class_name.split('.')[-1],\n",
390+
" focal_class=class_name.split(\".\")[-1],\n",
391391
" language=\"java\"\n",
392392
" )\n",
393393
" \n",
394394
" print(f\"Instruction:\\n{instruction}\\n\")\n",
395-
" print(f\"Generating code summary . . .\\n\")\n",
395+
" print(f\"Generating code summary ...\\n\")\n",
396396
" \n",
397397
" # Prompt the local model on Ollama\n",
398-
" llm_output = prompt_ollama(\n",
399-
" message=instruction\n",
400-
" )\n",
398+
" llm_output = prompt_ollama(message=instruction)\n",
401399
" \n",
402400
" # Print the LLM output\n",
403401
" print(f\"LLM Output:\\n{llm_output}\")"

docs/examples/java/notebook/generate_unit_tests.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@
285285
},
286286
"outputs": [],
287287
"source": [
288-
"# Create an instance CLDK for Java analysis\n",
288+
"# Create an instance of CLDK for Java analysis\n",
289289
"cldk = CLDK(language=\"java\")\n",
290290
"\n",
291291
"# Create an analysis object for the Java application. Provide the application path.\n",
292292
"analysis = cldk.analysis(project_path=\"/tmp/commons-cli-rel-commons-cli-1.7.0\", analysis_level=AnalysisLevel.symbol_table)\n",
293293
"\n",
294-
"# For simplicity, we run the test generation for a single focal class and method (this filter can be removed to run this code over the entire application)\n",
294+
"# For simplicity, we run the test generation on a single focal class and method (this filter can be removed to run this code over the entire application)\n",
295295
"focal_class = \"org.apache.commons.cli.GnuParser\"\n",
296296
"focal_method = \"flatten(Options, String[], boolean)\"\n",
297297
"\n",
@@ -334,7 +334,7 @@
334334
" focal_method=method.split(\"(\")[0],\n",
335335
" focal_class=focal_class_name,\n",
336336
" constructor_signatures=constructor_signatures,\n",
337-
" language=\"Java\"\n",
337+
" language=\"java\"\n",
338338
" )\n",
339339
" \n",
340340
" # Print the instruction\n",

0 commit comments

Comments
 (0)