Sentence case in German

A tough challenge for a hand coded algorithm but I reckon maybe it’s easy for a generative AI. I took my GPT-3 extension and modified it thus:

// #popclip
// name: DE Sentence (OpenAI)
// icon: circle de
// language: javascript
// after: paste-result
// entitlements: [network]
// options: [{identifier: apikey, label: API Key, type: string,
//   description: 'Obtain API key from https://platform.openai.com/account/api-keys'}] 
const openai = require("axios").create({
  baseURL: 'https://api.openai.com/v1/',
  headers: { Authorization: `Bearer ${popclip.options.apikey}` }
});
const { data } = await openai.post('edits', {
  model: 'text-davinci-edit-001',
  input: popclip.input.text,
  instruction: "Render this sentence with correct German capitalization"
});
return data.choices[0].text;

(The above block is an extension snippet - select the text it then click “Install Extension” when PopClip appears.)

Please note you will need to sign up for an account with OpenAI via https://openai.com/api/, and then get your API key from https://platform.openai.com/account/api-keys to insert in the extension config.

Testing it with the following sentence:

können sie mir helfen? ich feiere meinen geburtstag.

Können Sie mir helfen? Ich feiere meinen Geburtstag.

CleanShot 2023-02-22 at 12.45.23

So there we go! Looks promising.

1 Like