如何拆分英文西里尔文和西里尔文英文的句子?

How to split a sentence in English Cyrillic and Cyrillic English?

我有英文西里尔字母的示例文本:

“No,” the  old  man  said.” But we have .Haven’t we?” Бале , -гуфт  -Аммо мо бовар дорем . Дуруст”?  
“Yes ,”the boy said . Can I offer you a  beer on the  Terrace and then we’ll take the stuff home . 

 Албатта . Мехоҳӣ, ки дар каҳвахона  бароят оби ҷав  бигирам?  Баъд чизҳоро  ба хона  мебарем .  

“Why not ?”  the  old man said . “  Between fishermen.”  
Чаро  не ?! гуфт  пирамард .- Моҳигир моҳигириро метавонад  даъват кунад.

如何将示例结果从该文本获取到数组:

$englishCyrillic = [
   "No, the  old  man  said. But we have .Haven’t we?" => "Бале , -гуфт  -Аммо мо бовар дорем . Дуруст?",
   "Yes ,the boy said . Can I offer you a  beer on the  Terrace and then we’ll take the stuff home." => "Албатта . Мехоҳӣ, ки дар каҳвахона  бароят оби ҷав  бигирам?  Баъд чизҳоро  ба хона  мебарем.",
   "Why not ?  the  old man said . Between fishermen." => "Чаро  не ?! гуфт  пирамард .- Моҳигир моҳигириро метавонад  даъват кунад.",
];

还有我的西里尔英文句型:

Куҷо дард мекунад?  Show me where it hurts?    
Нафас гиред / Нафас нагиред.    Breath / Do not breath     
Чуқуртар нафас гиред    Breathe deeply

如何从本文中获取示例结果:

$cyrillicEnglish = [
   "Куҷо дард мекунад?" => "Show me where it hurts?",
   "Нафас гиред / Нафас нагиред." => "Breath / Do not breath",
   "Чуқуртар нафас гиред" => "Breathe deeply",
];

我厌倦了正则表达式,但我的代码不能按句子拆分,return 需要我的结果:

搜索英文单词:

preg_match_all('/[\p{Latin}]+/u', $text, $matches);

搜索西里尔字母:

preg_match_all('/[\p{Cyrillic}]+/u', $text, $matches);

第一种格式的字符串可以逐行读取,只需要将奇数添加为英文,偶数添加为西里尔文即可。不需要正则表达式。

对于第二种格式,您可以使用

preg_match('~(.*\p{Cyrillic}\S*)\h+(.+)~u', $s, $matches)

并创建数组:

array_combine($matches[1], $matches[2])

second regex demo