我有一个名为'string1'的字符串,
string1 = "Mr. Jorge Alexa Narvaez is a former Canadian cricketer and a politician.";
我还有另一个名为“string2”的字符串,它只有<NOUN> and </NOUN>
用空格分隔的“”标签包围的字符串。
string2 = "<NOUN>Jorge Alexa Narvaez</NOUN> <NOUN>Canadian</NOUN>";
请注意,第二个字符串可以有任何名词标记词(基于 'string1',例如:如果 string1 有 3 个名词,则 string2 将有相同的 3 个名词被名词标签包围)
我想将标签添加到 'string1' 和使 string1 如下,
string1 = "Mr. <NOUN>Jorge Alexa Narvaez</NOUN> is a former <NOUN>Canadian</NOUN> cricketer and a politician.";
只是我只想替换 'Jorge Alexa Narvaez' 和 'Canadian'<NOUN>Jorge Alexa Narvaez</NOUN> and <NOUN>Canadian</NOUN>
谁能告诉我该怎么做?