SummaryLength
Contents
[
Hide
]Inheritance: java.lang.Object
public class SummaryLength
Enumerates possible lengths of summary.
Examples:
Shows how to summarize text using OpenAI and Google models.
Document firstDoc = new Document(getMyDir() + "Big document.docx");
Document secondDoc = new Document(getMyDir() + "Document.docx");
String apiKey = System.getenv("API_KEY");
// Use OpenAI or Google generative language models.
IAiModelText model = (IAiModelText)AiModel.create(AiModelType.GPT_4_O_MINI).withApiKey(apiKey);
Document oneDocumentSummary = model.summarize(firstDoc, new SummarizeOptions(); { oneDocumentSummary.setSummaryLength(SummaryLength.SHORT); });
oneDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.One.docx");
Document multiDocumentSummary = model.summarize(new Document[] { firstDoc, secondDoc }, new SummarizeOptions(); { multiDocumentSummary.setSummaryLength(SummaryLength.LONG); });
multiDocumentSummary.save(getArtifactsDir() + "AI.AiSummarize.Multi.docx");
Fields
Field | Description |
---|---|
LONG | Try to generate 7-10 sentences. |
MEDIUM | Try to generate 5-6 sentences. |
SHORT | Try to generate 3-4 sentences. |
VERY_LONG | Try to generate 11-20 sentences. |
VERY_SHORT | Try to generate 1-2 sentences. |
length |
Methods
Method | Description |
---|---|
fromName(String summaryLengthName) | |
getName(int summaryLength) | |
getValues() | |
toString(int summaryLength) |
LONG
public static int LONG
Try to generate 7-10 sentences.
MEDIUM
public static int MEDIUM
Try to generate 5-6 sentences.
SHORT
public static int SHORT
Try to generate 3-4 sentences.
VERY_LONG
public static int VERY_LONG
Try to generate 11-20 sentences.
VERY_SHORT
public static int VERY_SHORT
Try to generate 1-2 sentences.
length
public static int length
fromName(String summaryLengthName)
public static int fromName(String summaryLengthName)
Parameters:
Parameter | Type | Description |
---|---|---|
summaryLengthName | java.lang.String |
Returns: int
getName(int summaryLength)
public static String getName(int summaryLength)
Parameters:
Parameter | Type | Description |
---|---|---|
summaryLength | int |
Returns: java.lang.String
getValues()
public static int[] getValues()
Returns: int[]
toString(int summaryLength)
public static String toString(int summaryLength)
Parameters:
Parameter | Type | Description |
---|---|---|
summaryLength | int |
Returns: java.lang.String