gpt4 book ai didi

c# - Humanizer 法语标题大小写支持

转载 作者:行者123 更新时间:2023-12-05 07:56:31 33 4
gpt4 key购买 nike

内置的 .Net 方法 TextInfo.ToTitleCase 可以很好地处理法语句子,但有些示例会导致问题,请参阅 remarks (复制如下):

Generally, title casing converts the first character of a word to uppercase and the rest of the characters to lowercase. However, this method does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym. The following table shows the way the method renders several strings.

Input Language Expected result Actual result
war and peace English War and Peace War And Peace
Per anhalter durch die Galaxis German Per Anhalter durch die Galaxis Per Anhalter Durch Die Galaxis
les naufragés d'ythaq French Les Naufragés d'Ythaq Les Naufragés D'ythaq

As illustrated above, the TextInfo.ToTitleCase method provides an arbitrary casing behavior which is not necessarily linguistically correct. A linguistically correct solution would require additional rules, and the current algorithm is somewhat simpler and faster. We reserve the right to make this API slower in the future.

The current implementation of the TextInfo.ToTitleCase method yields an output string that is the same length as the input string. However, this behavior is not guaranteed and could change in a future implementation.

Humanizer 库中是否有一个选项可以用给定的文化标题化?

最佳答案

感觉像是对 Humanizer 的一个很好的补充库,但目前不支持。

如果我要为法语实现标题大小写,我会查看 javascript titlecase-french库并在 C# 中重写它,遵循 rules 的好集它定义:

There are 5 main rules:

  • A title always starts with a word in uppercase
  • A specific list of words are in lowercase
  • After a quote ' words can be in lowercase or uppercase depending of the word before the quote
  • Acronyms are in uppercase
  • Special uppercase letters (with accent for example) are replaced with their simple version

TextInfo.ToTitleCase 注释 (les naufragés d'ythaq) 中的示例与 titlecase-french 一起正常工作:

console.log(require('titlecase-french').convert("les naufragés d'ythaq"));
// Les Naufragés d'Ythaq

关于c# - Humanizer 法语标题大小写支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28592944/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com