自然语言处理 NLP-文档翻译任务创建:请求示例
时间:2025-02-12 14:53:01
请求示例
- 请求示例(创建文档翻译任务)
POST https://{endpoint}/v1/{project_id}/machine-translation/file-translation/jobsRequest Header: Content-Type:application/json X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG... Request Body: { "url": "https://****.obs.cn-north-4.huawei.com/***.docx", "from": "zh", "to": "en", "type":"docx" }
- Python3语言请求代码示例(创建文档翻译任务)
# -*- coding: utf-8 -*-# 此demo仅供测试使用,建议使用sdk。需提前安装requests,执行pip install requestsimport requestsimport jsondef nlp_demo(): url = 'https://{endpoint}/v1/{project_id}/machine-translation/file-translation/jobs' # endpoint和project_id需替换 token = '用户对应region的token' header = { 'Content-Type': 'application/json', 'X-Auth-Token': token } body = { 'url': 'https://****.obs.cn-north-4.huawei.com/***.docx', 'from': 'zh', 'to': 'en', 'type':'docx' } resp = requests.post(url, data=json.dumps(body), headers=header) print(resp.json())if __name__ == '__main__': nlp_demo()
- Java语言请求代码示例(创建文档翻译任务)
import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.net.HttpURLConnection;import java.net.URL;/** * 此demo仅供测试使用,建议使用sdk */public class NLPDemo { public void nlpDemo() { try { //endpoint和projectId需要替换成实际信息。 URL url = new URL("https://{endpoint}/v1/{project_id}/machine-translation/file-translation/jobs"); String token = "对应region的token"; HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setDoInput(true); connection.setDoOutput(true); connection.addRequestProperty("Content-Type", "application/json"); connection.addRequestProperty("X-Auth-Token", token); //输入参数 //mtUrl请按照API说明,将文档上传至OBS后获取对应URL地址 String mtUrl = "https://*.obs.cn-north-4.myhuaweicloud.com/*.docx"; String from = "en"; String to = "zh"; String body = "{\"url\":\"" + mtUrl + "\" ,\"from\":\"" + from + "\" ,\"to\":\"" + to + "\" ,\"type\":\"docx\"}"; OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); osw.append(body); osw.flush(); InputStream is = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); while (br.ready()) { System.out.println(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { NLPDemo nlpDemo = new NLPDemo(); nlpDemo.nlpDemo(); }}
support.huaweicloud.com/api-nlp/nlp_03_0073.html
看了此文的人还看了
CDN加速
GaussDB
文字转换成语音
免费的服务器
如何创建网站
域名网站购买
私有云桌面
云主机哪个好
域名怎么备案
手机云电脑
SSL证书申请
云点播服务器
免费OCR是什么
电脑云桌面
域名备案怎么弄
语音转文字
文字图片识别
云桌面是什么
网址安全检测
网站建设搭建
国外CDN加速
SSL免费证书申请
短信批量发送
图片OCR识别
云数据库MySQL
个人域名购买
录音转文字
扫描图片识别文字
OCR图片识别
行驶证识别
虚拟电话号码
电话呼叫中心软件
怎么制作一个网站
Email注册网站
华为VNC
图像文字识别
企业网站制作
个人网站搭建
华为云计算
免费租用云托管
云桌面云服务器
ocr文字识别免费版
HTTPS证书申请
图片文字识别转换
国外域名注册商
使用免费虚拟主机
云电脑主机多少钱
鲲鹏云手机
短信验证码平台
OCR图片文字识别
SSL证书是什么
申请企业邮箱步骤
免费的企业用邮箱
云免流搭建教程
域名价格
推荐文章
- 全站加速请求收费_HTTPS请求数包_全站加速WSA
- 石墨文档网页版_石墨在线文档_石墨文档在线编辑_文档协同管理
- 分布式云原生集合示例_华为云分布式云原生_华为云UCS集合示例
- 调用GaussDB(DWS) API接口_数据仓库服务调用API_如何调用API_在DWS中调用API
- GaussDB文档_GaussDB数据库文档_高斯数据库文档_华为云
- 全站加速WSA_动态加速_全站加速请求数包
- 华为云CodeArts API_批量添加请求体参数
- 华为云资料 2021年 7月刊
- 代码检查工具_代码检查平台_代码检查CodeArts Check-华为云
- 106短信发送_短信接口API_短信群发助手
ServerLess102