Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

legal-summarization changedabout-claude/use-case-guides/legal-summarization

Nearest release: v2.1.309, published 3 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+75added
Lines−75removed
From line 88 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits11to this page, all time

The whole hunk

from line 88, old and new numbered
/
lines
from line 88
8888 
8989 ```java Java
9090 List<String> detailsToExtract = List.of(
91 "Parties involved (sublessor, sublessee, and original lessor)",
92 "Property details (address, description, and permitted use)",
93 "Term and rent (start date, end date, monthly rent, and security deposit)",
94 "Responsibilities (utilities, maintenance, and repairs)",
95 "Consent and notices (landlord's consent, and notice requirements)",
96 "Special provisions (furniture, parking, and subletting restrictions)");
91 "Parties involved (sublessor, sublessee, and original lessor)",
92 "Property details (address, description, and permitted use)",
93 "Term and rent (start date, end date, monthly rent, and security deposit)",
94 "Responsibilities (utilities, maintenance, and repairs)",
95 "Consent and notices (landlord's consent, and notice requirements)",
96 "Special provisions (furniture, parking, and subletting restrictions)");
9797 ```
9898 
9999 ```php PHP
from line 277
277277 return text;
278278 }
279279 
280 // Download the sample sublease agreement from the summarization cookbook
280 // Download the sample sublease agreement from the Claude Cookbook's summarization recipe
281281 const response = await fetch(
282282 "https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf"
283283 );
from line 306
306306 return text;
307307 }
308308 
309 // Download the sample sublease agreement from the summarization cookbook
309 // Download the sample sublease agreement from the Claude Cookbook's summarization recipe
310310 using var httpClient = new HttpClient();
311311 var pdfData = await httpClient.GetByteArrayAsync(
312312 "https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf"
from line 356
356356 
357357 // extractDocumentText downloads the sample sublease agreement and extracts its text.
358358 func extractDocumentText() {
359 // Download the sample sublease agreement from the summarization cookbook
359 // Download the sample sublease agreement from the Claude Cookbook's summarization recipe
360360 response, err := http.Get("https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf")
361361 if err != nil {
362362 log.Fatal(err)
from line 402
402402 }
403403 
404404 void extractDocumentText() throws IOException, InterruptedException {
405 // Download the sample sublease agreement from the summarization cookbook
405 // Download the sample sublease agreement from the Claude Cookbook's summarization recipe
406406 HttpRequest request = HttpRequest.newBuilder(URI.create(
407 "https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf"))
408 .build();
407 "https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf"))
408 .build();
409409 byte[] pdfData;
410410 try (HttpClient httpClient = HttpClient.newHttpClient()) {
411411 pdfData = httpClient.send(request, HttpResponse.BodyHandlers.ofByteArray()).body();
from line 430
430430 return preg_replace('/\s+/', ' ', $text);
431431 };
432432 
433 // Download the sample sublease agreement from the summarization cookbook
433 // Download the sample sublease agreement from the Claude Cookbook's summarization recipe
434434 $pdfData = file_get_contents(
435435 'https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf'
436436 );
from line 455
455455 text.gsub(/\s+/, " ")
456456 end
457457 
458 # Download the sample sublease agreement from the summarization cookbook
458 # Download the sample sublease agreement from the Claude Cookbook's summarization recipe
459459 pdf_data = Net::HTTP.get(
460460 URI("https://raw.githubusercontent.com/anthropics/claude-cookbooks/main/capabilities/summarization/data/Sample%20Sublease%20Agreement.pdf")
461461 )
from line 701
701701 
702702 // Prompt the model to summarize the sublease agreement
703703 String prompt = """
704 Summarize the following sublease agreement. Focus on these key aspects:
704 Summarize the following sublease agreement. Focus on these key aspects:
705705 
706 %s
706 %s
707707 
708 Provide the summary in bullet points nested within the XML header for each section. For example:
708 Provide the summary in bullet points nested within the XML header for each section. For example:
709709 
710 <parties involved>
711 - Sublessor: [Name]
712 // Add more details as needed
713 </parties involved>
710 <parties involved>
711 - Sublessor: [Name]
712 // Add more details as needed
713 </parties involved>
714714 
715 If any information is not explicitly stated in the document, note it as "Not specified". Do not preamble.
715 If any information is not explicitly stated in the document, note it as "Not specified". Do not preamble.
716716 
717 Sublease agreement text:
718 %s
719 """
720 .formatted(detailsToExtractStr, text);
717 Sublease agreement text:
718 %s
719 """
720 .formatted(detailsToExtractStr, text);
721721 
722722 Message response = client.messages().create(MessageCreateParams.builder()
723 .model(model)
724 .maxTokens(maxTokens)
725 .system("You are a legal analyst specializing in real estate law, known for highly accurate and detailed summaries of sublease agreements.")
726 .addUserMessage(prompt)
727 .build());
723 .model(model)
724 .maxTokens(maxTokens)
725 .system("You are a legal analyst specializing in real estate law, known for highly accurate and detailed summaries of sublease agreements.")
726 .addUserMessage(prompt)
727 .build());
728728 
729729 return response.content().stream()
730 .flatMap(block -> block.text().stream())
731 .findFirst()
732 .orElseThrow()
733 .text();
730 .flatMap(block -> block.text().stream())
731 .findFirst()
732 .orElseThrow()
733 .text();
734734 }
735735 
736736 void printSubleaseSummary() {
737737 String subleaseSummary = summarizeDocument(
738 documentText, detailsToExtract, Model.CLAUDE_OPUS_5_5, 16000);
738 documentText, detailsToExtract, Model.CLAUDE_OPUS_5_5, 16000);
739739 IO.println(subleaseSummary);
740740 }
741741 ```
from line 1157
11571157 ```java Java
11581158 List<String> chunkText(String text, int chunkSize) {
11591159 return IntStream.iterate(0, start -> start < text.length(), start -> start + chunkSize)
1160 .mapToObj(start -> text.substring(start, Math.min(start + chunkSize, text.length())))
1161 .toList();
1160 .mapToObj(start -> text.substring(start, Math.min(start + chunkSize, text.length())))
1161 .toList();
11621162 }
11631163 
11641164 String summarizeLongDocument(String text, List<String> detailsToExtract, Model model, long maxTokens) {
from line 1167
11671167 
11681168 // Iterate over chunks and summarize each one
11691169 String chunkSummaries = chunkText(text, 20000).stream()
1170 .map(chunk -> summarizeDocument(chunk, detailsToExtract, model, maxTokens))
1171 .collect(Collectors.joining());
1170 .map(chunk -> summarizeDocument(chunk, detailsToExtract, model, maxTokens))
1171 .collect(Collectors.joining());
11721172 
11731173 String finalSummaryPrompt = """
11741174 
1175 You are looking at the chunked summaries of multiple documents that are all related.
1176 Combine the following summaries of the document from different truthful sources into a coherent overall summary:
1175 You are looking at the chunked summaries of multiple documents that are all related.
1176 Combine the following summaries of the document from different truthful sources into a coherent overall summary:
11771177 
1178 <chunked_summaries>
1179 %s
1180 </chunked_summaries>
1178 <chunked_summaries>
1179 %s
1180 </chunked_summaries>
11811181 
1182 Focus on these key aspects:
1183 %s
1182 Focus on these key aspects:
1183 %s
11841184 
1185 Provide the summary in bullet points nested within the XML header for each section. For example:
1185 Provide the summary in bullet points nested within the XML header for each section. For example:
11861186 
1187 <parties involved>
1188 - Sublessor: [Name]
1189 // Add more details as needed
1190 </parties involved>
1187 <parties involved>
1188 - Sublessor: [Name]
1189 // Add more details as needed
1190 </parties involved>
11911191 
1192 If any information is not explicitly stated in the document, note it as "Not specified". Do not preamble.
1193 """
1194 .formatted(chunkSummaries, detailsToExtractStr);
1192 If any information is not explicitly stated in the document, note it as "Not specified". Do not preamble.
1193 """
1194 .formatted(chunkSummaries, detailsToExtractStr);
11951195 
11961196 Message response = client.messages().create(MessageCreateParams.builder()
1197 .model(model)
1198 .maxTokens(maxTokens)
1199 .system("You are a legal expert that summarizes notes on one document.")
1200 .addUserMessage(finalSummaryPrompt)
1201 .build());
1197 .model(model)
1198 .maxTokens(maxTokens)
1199 .system("You are a legal expert that summarizes notes on one document.")
1200 .addUserMessage(finalSummaryPrompt)
1201 .build());
12021202 
12031203 return response.content().stream()
1204 .flatMap(block -> block.text().stream())
1205 .findFirst()
1206 .orElseThrow()
1207 .text();
1204 .flatMap(block -> block.text().stream())
1205 .findFirst()
1206 .orElseThrow()
1207 .text();
12081208 }
12091209 
12101210 void printLongSummary() {
12111211 String longSummary = summarizeLongDocument(
1212 documentText, detailsToExtract, Model.CLAUDE_OPUS_5_5, 16000);
1212 documentText, detailsToExtract, Model.CLAUDE_OPUS_5_5, 16000);
12131213 IO.println(longSummary);
12141214 }
12151215 ```
Feedback