Tüm Ürünler
Search
Belge Merkezi

Object Storage Service:Intelligent document summarization

Son Güncelleme:Oct 01, 2026

Akıllı belge özetleme, uzun belgeleri otomatik olarak belgenin ana noktalarını vurgulayan kısa özetlere dönüştürür. Bu işlem, okuyucuların tüm belgeyi okuma zahmetinden kurtarır ve içeriği hızlıca kavramalarına olanak tanır.

Ön koşullar

İlgili Object Storage Service (OSS) paketinin bir Intelligent Media Management (IMM) projesine bağlı olması gerekir. OSS konsolunda bir OSS paketini IMM projesine bağlama hakkında daha fazla bilgi için bkz. Hızlı başlangıç. IMM API kullanarak bir OSS paketini IMM projesine bağlama hakkında daha fazla bilgi için bkz. AttachOSSBucket.

Kullanım notları

  • Akıllı belge özetleme yalnızca eşzamanlı işlemeyi (x-oss-process) destekler.

  • Akıllı belge özetleme özelliğini kullanmak için istekleri POST yöntemiyle gönderin.

  • Anonim erişim reddedilir.

  • Özelliği kullanmak için gerekli izinlere sahip olmanız gerekir. Daha fazla bilgi için bkz. izinler.

Parametreler

Eylem: doc/summarize

Aşağıdaki tabloda, akıllı belge özetleme özelliğini kullanırken belirtebileceğiniz parametreler açıklanmaktadır.

Parametre

Tür

Gerekli

Açıklama

content

string

Evet

Özetlemek istediğiniz içerik. İçerik URL güvenli Base64 ile kodlanmalıdır.

Not

İçerik en fazla 19.500 bayt uzunluğunda olabilir.

format

string

Hayır

Yanıtı döndürme modu. Geçerli değerler:

  • json (varsayılan): normal mod. Tam yanıtı içeren bir veri paketi döndürülür.

  • event-stream: sunucu gönderimli olaylar (SSE) modu. Birden çok paket döndürülür. Her paket tam veriyi içerir.

Aşağıdaki tabloda yanıt parametreleri açıklanmaktadır.

Parametre

Tür

Açıklama

RequestId

string

İstek kimliği.

Output

struct

Çıktı.

Alt düğümler: Text ve FinishReason

Text

string

Özet.

Üst düğüm: Output

FinishReason

string

Özetleme görevinin durumu. Geçerli değerler:

  • null: Görev çalışıyor.

  • stop: Görev sonlandırıldı.

Üst düğüm: Output

RESTful API kullanma

Not

Bir belgeyi özetlemek için RESTful API kullanıyorsanız, yalnızca yer tutucu olarak kullanılan belge adını belirtin. Akıllı belge özetleme, yalnızca content parametresinin değerini özetlenecek metin olarak tanımlar.

Belgeleri normal modda özetleme

İşleme yöntemi

  • İşlenecek belge: example.doc

  • Özetlenecek metin: Ernest Hemingway'in "The Old Man and the Sea" adlı eseri, yaşlı bir balıkçı olan Santiago'nun dev bir marlini yakalamak için verdiği epik mücadeleyi anlatır. Bu hikaye, insan dayanıklılığı, azmi ve doğanın güçlerine karşı verilen mücadeleye dair derin bir keşiftir. Santiago'nun zorluklar karşısındaki sarsılmaz kararlılığı ve onuru, insan ruhunun gücünün bir kanıtıdır.

  • Yanıt formatı: JSON

Örnek istek

POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e

x-oss-process=doc/summarize,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Zu95paH5a2m5a6d5bqT5Lit55qE55KA55Ko5piO54-g77yM5piv5Lit5Zu95Y-k5Luj5bCP6K-06Im65pyv5beF5bOw55qE6LGh5b6B44CC6L-Z5Zub6YOo5Li-5LiW6Ze75ZCN55qE5bCP6K-05beo6JGX77yM5YiG5Yir5piv572X6LSv5Lit5omA5Yib5L2c55qE5Y6G5Y-y6aKY5p2Q5bCP6K-044CK5LiJ5Zu95ryU5LmJ44CL77yM5ZC05om_5oGp56yU5LiL55qE56We6a2U5aWH5bm75L2c5ZOB44CK6KW_5ri46K6w44CL77yM5pa96ICQ5bq15Yib5L2c55qE6Iux6ZuE5Lyg5aWH5bCP6K-044CK5rC05rWS5Lyg44CL77yM5Lul5Y-K5pu56Zuq6Iq55pKw5YaZ55qE5Lq65oOF5LiW5pWF5LiO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ıt

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:09:00 GMT
Content-Type: application/json;charset=UTF-8
Connection: close
Vary: Accept-Encoding
x-oss-request-id: 676144309D4E643133E487D4
x-oss-server-time: 2010
Content-Encoding: gzip

{
  "RequestId":"676144309D4E643133E487D4",
  "Output":{
    "Text":"\"The Old Man and the Sea\" by Ernest Hemingway is a narrative about an elderly fisherman, Santiago, who embarks on an epic journey to catch a massive marlin. The story delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.",
    "FinishReason":"stop"
  }
}

Belgeleri SSE modunda özetleme

İşleme yöntemi

  • İşlenecek belge: example.doc

  • Özetlenecek metin: Ernest Hemingway'in "The Old Man and the Sea" adlı eseri, yaşlı bir balıkçı olan Santiago'nun dev bir marlini yakalamak için verdiği epik mücadeleyi anlatır. Bu hikaye, insan dayanıklılığı, azmi ve doğanın güçlerine karşı verilen mücadeleye dair derin bir keşiftir. Santiago'nun zorluklar karşısındaki sarsılmaz kararlılığı ve onuru, insan ruhunun gücünün bir kanıtıdır.

  • Yanıt formatı: event-stream

Örnek istek

POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e

x-oss-process=doc/summarize,format_event-stream,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Zu95paH5a2m5a6d5bqT5Lit55qE55KA55Ko5piO54-g77yM5piv5Lit5Zu95Y-k5Luj5bCP6K-06Im65pyv5beF5bOw55qE6LGh5b6B44CC6L-Z5Zub6YOo5Li-5LiW6Ze75ZCN55qE5bCP6K-05beo6JGX77yM5YiG5Yir5piv572X6LSv5Lit5omA5Yib5L2c55qE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J5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CC

Örnek yanıt

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:20:11 GMT
Content-Type: text/event-stream;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
x-oss-request-id: 669F7CE338492236349AF037
x-oss-server-time: 587

id: 0
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The","FinishReason":"null"}}

id: 1
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old","FinishReason":"null"}}

id: 2
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man","FinishReason":"null"}}

id: 3
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and","FinishReason":"null"}}

id: 4
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by","FinishReason":"null"}}

id: 5
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway","FinishReason":"null"}}

id: 6
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story","FinishReason":"null"}}

id: 7
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an","FinishReason":"null"}}

id: 8
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman,","FinishReason":"null"}}

id: 9
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his ardu","FinishReason":"null"}}

id: 10
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch","FinishReason":"null"}}

id: 11
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin","FinishReason":"null"}}

id: 12
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative del","FinishReason":"null"}}

id: 13
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of","FinishReason":"null"}}

id: 14
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance","FinishReason":"null"}}

id: 15
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle","FinishReason":"null"}}

id: 16
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago","FinishReason":"null"}}

id: 17
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and","FinishReason":"null"}}

id: 18
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight","FinishReason":"null"}}

id: 19
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the","FinishReason":"null"}}

id: 20
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.","FinishReason":"stop"}}

OSS SDK'lerini kullanma

Aşağıdaki örnek kod, yaygın programlama dilleri için Object Storage Service (OSS) SDK'larını kullanarak bir belgenin nasıl özetleneceğine ilişkin örnekler sunar. Başka programlama dilleri için OSS SDK'larını kullanarak belgeleri özetlemek isterseniz aşağıdaki örnek koda göre parametreleri değiştirin.

Java

OSS SDK for Java V3.17.4 veya sonraki bir sürüm gereklidir.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.IOUtils;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.ProcessObjectRequest;

import java.io.IOException;
import java.util.Formatter;

public class Demo {
    public static void main(String[] args) throws ClientException, com.aliyuncs.exceptions.ClientException {
        // Specify the endpoint of the region in which the bucket is located. 
        String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
        // Specify the ID of the Alibaba Cloud region in which the bucket is located. Example: cn-hangzhou. 
        String region = "cn-hangzhou";
        // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the name of the bucket. 
        String bucketName = "examplebucket";
        // Specify the name of the document object, which is used only as a placeholder. Intelligent document summarization does not read the content of the document. 
        String key ="example.docx";
        // Specify the text content to be summarized. 
        String content = "yourContent";
        String encodeContent = BinaryUtil.toBase64String(content.getBytes()).replaceAll("\\+","-")
                .replaceAll("/","_").replaceAll("=","");

        // Create an OSSClient instance.
        // Call the shutdown method to release resources when the OSSClient is no longer in use. 
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {

            StringBuilder sbStyle = new StringBuilder();
            Formatter styleFormatter = new Formatter(sbStyle);
            // Create a processing instruction for intelligent document summarization. 
            styleFormatter.format("doc/summarize,content_%s",
                    encodeContent);
            System.out.println(sbStyle.toString());
            ProcessObjectRequest request = new ProcessObjectRequest(bucketName, key, sbStyle.toString());
            GenericResult processResult = ossClient.processObject(request);
            String json = IOUtils.readStreamAsString(processResult.getResponse().getContent(), "UTF-8");
            processResult.getResponse().getContent().close();
            System.out.println(json);
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

PHP

OSS SDK for PHP V2.7.0 veya sonraki bir sürüm gereklidir.

<?php
// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.  
$ak = getenv('OSS_ACCESS_KEY_ID');
$sk = getenv('OSS_ACCESS_KEY_SECRET');
// Specify the name of the bucket. Example: examplebucket. 
$bucket = 'examplebucket';
// Specify the name of the document object, which is used only as a placeholder. Intelligent document summarization does not read the content of the document. 
$objectKey = 'example.docx';
// Specify the text content to be summarized. 
$txt = "yourTxt";

$base64url = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($txt));
// Create a processing instruction for intelligent document summarization. 
$body = sprintf("x-oss-process=doc/summarize,content_%s", $base64url);

$httpVerb = 'POST';
$contentMd5 = base64_encode(md5($body, true));
$contentType = '';
$date = gmdate('D, d M Y H:i:s T');
$stringToSign = $httpVerb . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . "/{$bucket}/{$objectKey}?x-oss-process";
$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://{$bucket}.oss-cn-hangzhou.aliyuncs.com/{$objectKey}?x-oss-process");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Date: ' . $date,
    'Authorization: OSS ' . $ak . ':' . $signature,
    'Content-Type: ' . $contentType,
    'Content-Md5:' . $contentMd5,
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);

$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($response === false) {
    echo "Error: " . curl_error($ch);
} else {
    if ($httpcode == 200) {
        var_dump($response);
    } else {
        echo "Error: HTTP code " . $httpcode;
    }
}

Go

OSS SDK for Go V3.0.2 veya sonraki bir sürüm gereklidir.

package main

import (
    "encoding/base64"
    "encoding/json"
    "fmt"
    "io"
    "os"
    "strings"

    "github.com/aliyun/aliyun-oss-go-sdk/oss"
)

type TextData struct {
    RequestId string `json:"RequestId"`
    Output    struct {
    Text         string `json:"Text"`
    FinishReason string `json:"FinishReason"`
    } `json:"Output"`
}

func main() {
    // Obtain the temporary access credentials from the environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET, and OSS_SESSION_TOKEN environment variables are configured. 
    provider, err := oss.NewEnvironmentVariableCredentialsProvider()
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    // Create an OSSClient instance. 
    client, err := oss.New("https://oss-cn-hangzhou.aliyuncs.com", "", "", oss.SetCredentialsProvider(&provider), oss.AuthVersion(oss.AuthV4), oss.Region("cn-hangzhou"))
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }

    // Specify the name of the bucket. Example: examplebucket. 
    bucketName := "examplebucket"
    bucket, err := client.Bucket(bucketName)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    params := make(map[string]interface{})
    params["x-oss-process"] = nil
    // Specify the text content to be summarized. 
    txt := "yourTxt"
    // Create a processing instruction for intelligent document summarization. 
    data := fmt.Sprintf("x-oss-process=doc/summarize,content_%v", base64.URLEncoding.EncodeToString([]byte(txt)))
    // example.docx is a document in the bucket. It is used as a placeholder. Intelligent document summarization does not read the content of the document. 
    response, err := bucket.Do("POST", "example.docx", params, nil, strings.NewReader(data), nil)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }

    defer response.Body.Close()
    jsonData, err := io.ReadAll(response.Body)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    var text TextData
    err = json.Unmarshal(jsonData, &text)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    fmt.Printf("RequestId:%v\n", text.RequestId)
    fmt.Printf("Text:%v\n", text.Output.Text)
    fmt.Printf("FinishReason:%v\n", text.Output.FinishReason)
}