如何去除中英混合文本中的中文或英文?

xujiajin

管理员
Staff member
如果有一个中英文混合的文本,比如对译文本。
如何可以一次性将其中的中文剔除或者将其中的英文剔除?
 
假如能够找到它们的代码(这肯定不容易啊),有可能去掉。
 
回复:如何去除中英混合文本中的中文或英文?

以下是引用 xujiajin2005-9-11 9:26:52 的发言:
如果有一个中英文混合的文本,比如对译文本。
如何可以一次性将其中的中文剔除或者将其中的英文剔除?

用ACWT里边的工具加上NoteTab自身的正则表达方式试了一下。具体做法是去英文
保中文。(Not pretty but works!)

2005091111153226.jpg


2005091111160718.jpg


2005091111173363.jpg
 
Or maybe like this file: you want to "de-align" English from Chinese and save them as two separate files? And you have a lot of such files rather than just a dozen of them which you can process one by one? It's a piece of cake.

<p>
<s n="L1E_0001"> The_AT Future_NN1 of_IO Africa_NP1 </s>
<s n="L2C_0001"> 非洲_ns 的_u 未来_t </s>
</p>
<p>
<s n="L1E_0002"> We_PPIS2 are_VBR in_II a_AT1 period_NN1 of_IO decisive_JJ historical_JJ significance_NN1 for_IF Africa_NP1 and_CC its_APPGE place_NN1 in_II the_AT world_NN1 ._. </s>
<s n="L2C_0002"> 我们_r 非洲_ns 及其_c 在_p 世界_n 的_u 地位_n 正_d 处在_v 决定性_n 并_c 具_vg 历史_n 意义_n 的_u 时期_n 。_w </s>
<s n="L1E_0003"> We_PPIS2 are_VBR determined_VVN that_CST this_DD1 2lst_FO century_NNT1 shall_VM be_VBI the_AT African_JJ century_NNT1 ._. </s>
<s n="L2C_0003"> 我们_r 决心_d 要_v 使_v 21_m 世纪_n 成为_v 非洲_ns 的_u 世纪_n 。_w </s>
</p>
<p>
<s n="L1E_0004"> The_AT idea_NN1 of_IO an_AT1 African_JJ renaissance_NN1 has_VHZ taken_VVN hold_NN1 in_II our_APPGE continent_NN1 with_IW all_DB the_AT resonance_NN1 of_IO an_AT1 idea_NN1 whose_DDQGE time_NNT1 has_VHZ come_VVN ._. </s>
<s n="L2C_0004"> 非洲_ns 复兴_vn 的_u 理想_n 已_d 在_p 我们_r 大陆_n 扎_v 下_f 根_n ,_w 这_r 理想_n 实现_v 的_u 时刻_n 已经_d 到来_v ,_w 这_r 想法_n 引起_v 大家_r 的_u 共鸣_vn 。_w </s>
<s n="L1E_0005"> The_AT rebirth_NN1 we_PPIS2 are_VBR engaged_VVN in_II is_VBZ not_XX one_PN1 that_CST will_VM culminate_VVI ,_, as_CSA European_JJ renaissance_NN1 did_VDD ,_, in_II colonization_NN1 and_CC dominance_NN1 of_IO a_AT1 world_NN1 economic_JJ system_NN1 ,_, of_IO which_DDQ the_AT slave_NN1 trade_NN1 was_VBDZ an_AT1 integral_JJ part_NN1 ._. </s>
<s n="L2C_0005"> 我们_r 所_u 追求_v 的_u 复兴_vn ,_w 其_r 结果_n 将_d 不_d 是_v 像_p 欧洲_ns 复兴_v 那样_r ,_w 导致_v 殖民主义_n ,_w 导致_v 以_p 奴隶_n 贩卖_v 为_p 其_r 组成部分_l 的_u 经济_n 制度_n 主宰_v 世界_n 。_w </s>
<s n="L1E_0006"> Ours_PPGE is_VBZ ,_, however_RR ,_, a_AT1 rebirth_NN1 that_CST must_VM deal_VVI with_IW problems_NN2 that_CST derive_VV0 from_II Africa_NP1 's_GE historical_JJ relation_NN1 with_IW the_AT rest_NN1 of_IO the_AT world_NN1 ,_, established_VVN in_II that_DD1 period_NN1 ._. </s>
<s n="L2C_0006"> 然而_c 我们_r 的_u 复兴_vn 必须_d 解决_v 一_m 系列_q 问题_n ,_w 这些_r 问题_n 是_v 源于_v 在_p 那_r 个_q 时期_n 所_u 建立_v 的_u 非洲_ns 和_c 外部_f 世界_n 的_u 历史性_n 关系_n 。_w </s>
<s n="L1E_0007"> And_CC this_DD1 must_VM be_VBI achieved_VVN in_II a_AT1 rapidly_RR globalizing_VVG world_NN1 ._. </s>
<s n="L2C_0007"> 而_c 这_r 必须_d 在_p 一个_m 迅速_ad 全球化_v 的_u 世界_n 里_f 进行_v 。_w </s>
<s n="L1E_0008"> A_AT1 second_MD historical_JJ project_NN1 ,_, related_VVN to_II the_AT first_MD ,_, is_VBZ that_DD1 of_IO building_VVG strong_JJ institutions_NN2 in_II a_AT1 united_JJ continent_NN1 ._. </s>
<s n="L2C_0008"> 同_p 上述_b 有关_vn 的_u 第二_m 个_q 历史性_n 工程_n ,_w 就是_v 在_p 团结_a 的_u 非洲_ns 大陆_n 上_f 建立_v 坚强_a 的_u 制度_n 体系_n ,_w </s>
<s n="L1E_0009"> Political_JJ ,_, economic_JJ and_CC social_JJ institutions_NN2 at_II national_JJ ,_, regional_JJ and_CC continental_JJ level_NN1 ..._... </s>
<s n="L2C_0009"> 即_v 国家_n 级_q 、_w 地区_n 级_n 和_c 大陆_n 级_q 的_u 政治_n 、_w 经济_n 和_c 社会_n 机制_n 。_w </s>
</p>
 
Thank 动态语法 for the help.
Any idea if I want to remove Chinese texts and keep English texts?

I have looked up in the regular expressions and not come up with a good solution.
 
回复:如何去除中英混合文本中的中文或英文?

以下是引用 xujiajin2005-9-11 9:26:52 的发言:
如果有一个中英文混合的文本,比如对译文本。
如何可以一次性将其中的中文剔除或者将其中的英文剔除?

巧用MS Word的“查找/替换"功能,如“高级选项”,可用以下步骤:
1. 查找 “任意字母^$”,并替换成 斜体 (或粗体或下划线等,在“格式->字体”中设)。
2. 剔除英文:查找 “斜体”“任意字符^?”,并替换成 其它(最好是空格);
剔除中文:查找 “非斜体”“任意字符^?”,并替换成 其它(最好是空格);
那英文中的标点和数字该怎么办? 相信现在你会有办法的。
 
如果文本数量多,可以利用Word把宏(macro) 录制好,即把剔除英文或汉字的过程纪录下来,以后每次操作,使用对应的macro就可以了.
 
But there are also legitimate English letters, numerals and punctuations in Chinese texts that are input in the "half-mode".

A more common senerio where Chinese needs to be separated from English is a parallel corpus mixed with English and Chinese sentences/paragraphs, which must be separated and saved into different files for use with Paraconc.
 
基本可以满足我的需求。但在剔除中文的操作中,阿拉伯数字,英文标点符号也一并被去掉了。
 
回复:如何去除中英混合文本中的中文或英文?

以下是引用 xujiajin2005-9-13 1:07:42 的发言:
基本可以满足我的需求。但在剔除中文的操作中,阿拉伯数字,英文标点符号也一并被去掉了。
If you want to keep half-width numbers and punc marks, do a similiar (not the same) pre-processisng to them as you did with the letters. You will solve this problem with only a little more trying.
 
回复:如何去除中英混合文本中的中文或英文?

Pre-process the text first by "Find and Replace" all half-mode numerals, punctuations and alphabet letters into full-mode ones.
 
回复:如何去除中英混合文本中的中文或英文?

以下是引用 xujiajin2005-9-12 15:02:03 的发言:
Thank 动态语法 for the help.
Any idea if I want to remove Chinese texts and keep English texts?

I have looked up in the regular expressions and not come up with a good solution.

It may take a little more than a simple RegExp. Here is a NoteTab clip
(BilingualExtractor) I wrote. It will keep your original file intact, separate the
Chinese portion of the text from the English portion, and finally output
each as CHIN_OUT.txt and ENG_OUT.txt, respectively.

Use:
1) Save the clip to ..\NoteTab Light\Libraries;
2) POS tag your bilingual text with ICTCLAS;
(you can find this from within ACWT; for the required
settings for this step, read a previous post/screen shot on page 1);
3) Open up the POS tagged file (xxx.cla.txt) with NoteTab Light;
4) Find and apply BilingualExtractor (command title is C-E Extractor);
5) Hope it works okay.

It will Not work if (among other things):
- The file is not a clean ASCII text file;
- The English portion of the text is not clean ASCII (e.g. the Chinese fake
version of English letters);
- Your text is not processed in the right way by ICTCLAS.

For the NoteTab clip:

http://www.corpus4u.org/upload/forum/2005091505244723.zip
 
回复:如何去除中英混合文本中的中文或英文?

用例:金山词霸条目 (怪字为国际音标变形后的形状,余同。)

corpus
AHD:[krps]
D.J.:[6k%8rp*s]
K.K.:[6k%rp*s]
n.
pl. cor.po.ra;
AHD:[-pr-]abbr:cor.
A large collection of writings of a specific kind or on a specific subject.
The principal or capital, as distinguished from the interest or income, as of a fund or estate.
Anatomy
The main part of a bodily structure or organ.
A distinct bodily mass or organ having a specific function.
Music
The overall length of a violin.

Middle English
fromLatin
*See Also : kw In Appendixrep-

corpus
AHD:[krps]
D.J.:[6k%8rp*s]
K.K.:[6k%rp*s]
n.
pl. cor.po.ra;
【复数】 cor.po.ra;
AHD:[-pr-]abbr:cor.
A large collection of writings of a specific kind or on a specific subject.
丛书某一特种的或有关某一主题的大型系列文献
The principal or capital, as distinguished from the interest or income, as of a fund or estate.
资金基金或资产的本金或资本,以区别于利息或收入
Anatomy
【解剖学】
The main part of a bodily structure or organ.
主体身体结构或器官的主要部分
A distinct bodily mass or organ having a specific function.
器官具有某一功能的明显的身体部位或器官
Music
【音乐】
The overall length of a violin.
小提琴的总长

Middle English
中古英语
fromLatin
源自拉丁语
*See Also : kw In Appendixrep-

corpus
[5kC:pEs]
n
文集,全集

corpus
[5kC:pEs]
n.
(pl. -pora[-pErE])
身体
[谑]躯体, 尸体
文献, 文集, 大全
(事物的)主体
本金
【解】(脂肪)体;【植】原体
corpus adiposum
脂肪体
corpus callosum
胼胝体
corpus delicti [di5liktai]
【律】犯罪事实; (谋杀案中的)被杀尸体

corpus juris
[5dVuEris]
法令大全, 法典 corpus luteum【解】黄体 corpus striatum 【解】纹状体

actual corpus
实际财产主体(如区别于利息的本金)
estate corpus
遗产本值
habeas corpus
[5heibjEs5kC:pEs]
人身保护权
trust corpus
信托资产本值

corpus
[5kC:pEs]
n.尸体, 文集, (某项基金的)本金
 
回复:如何去除中英混合文本中的中文或英文?

经过ICTCLAS分词(BilingualExtractor需要在这个文本的基础上作双语分割):

corpus/nx
AHD:/nx [/w k/nx r/g p s ]/w
D.J.:/nx [/w 6k%8rp*s/nx ]/w
K.K.:/nx [/w 6k%rp*s/nx ]/w
n./nx
pl./nx cor.po.ra;/nx
AHD:/nx [/w -p/nx r -/m ] abbr:/nx cor./nx
A/nx large/nx collection/nx of/nx writings/nx of/nx a/nx specific/nx kind/nx or/nx on/nx a/nx specific/nx subject./nx
The/nx principal/nx or/nx capital/nx ,/w as/nx distinguished/nx from/nx the/nx interest/nx or/nx income/nx ,/w as/nx of/nx a/nx fund/nx or/nx estate./nx
Anatomy/nx
The/nx main/nx part/nx of/nx a/nx bodily/nx structure/nx or/nx organ./nx
A/nx distinct/nx bodily/nx mass/nx or/nx organ/nx having/nx a/nx specific/nx function./nx
Music/nx
The/nx overall/nx length/nx of/nx a/nx violin./nx

Middle/nx English/nx
fromLatin/nx
*See/nx Also/nx :/nx kw/nx In/nx Appendixrep-/nx

corpus/nx
AHD:/nx [/w k/nx r/g p s ]/w
D.J.:/nx [/w 6k%8rp*s/nx ]/w
K.K.:/nx [/w 6k%rp*s/nx ]/w
n./nx
pl./nx cor.po.ra;/nx
【/w 复数/n 】/w cor.po.ra;/nx
AHD:/nx [/w -p/nx r -/m ] abbr:/nx cor./nx
A/nx large/nx collection/nx of/nx writings/nx of/nx a/nx specific/nx kind/nx or/nx on/nx a/nx specific/nx subject./nx
丛书/n 某/r 一/m 特种/b 的/u 或/c 有关/p 某/r 一/m 主题/n 的/u 大型/b 系列/n 文献/n
The/nx principal/nx or/nx capital/nx ,/w as/nx distinguished/nx from/nx the/nx interest/nx or/nx income/nx ,/w as/nx of/nx a/nx fund/nx or/nx estate./nx
资金/n 基金/n 或/c 资产/n 的/u 本金/n 或/c 资本/n ,/w 以/p 区别/n 于/p 利息/n 或/c 收入/n
Anatomy/nx
【/w 解剖学/n 】/w
The/nx main/nx part/nx of/nx a/nx bodily/nx structure/nx or/nx organ./nx
主体/n 身体/n 结构/n 或/c 器官/n 的/u 主要/b 部分/n
A/nx distinct/nx bodily/nx mass/nx or/nx organ/nx having/nx a/nx specific/nx function./nx
器官/n 具有/v 某/r 一/m 功能/n 的/u 明显/a 的/u 身体/n 部位/n 或/c 器官/n
Music/nx
【/w 音乐/n 】/w
The/nx overall/nx length/nx of/nx a/nx violin./nx
小提琴/n 的/u 总/b 长/a

Middle/nx English/nx
中/j 古/j 英语/nz
fromLatin/nx
源自/v 拉丁语/n
*See/nx Also/nx :/nx kw/nx In/nx Appendixrep-/nx

corpus/nx
[/w 5kC:/nx pEs/nx ]/w
n/nx
文集/n ,/w 全集/n

corpus/nx
[/w 5kC:/nx pEs/nx ]/w
n./nx
(/w pl./nx -pora/nx [/w -pErE/nx ]/w )/w
身体/n
[/w 谑/g ]/w 躯体/n ,/w 尸体/n
文献/n ,/w 文集/n ,/w 大全/n
(/w 事物/n 的/u )/w 主体/n
本/r 金/ng
【/w 解/v 】/w (/w 脂肪/n )/w 体/ng ;/w 【/w 植/v 】/w 原/b 体/n
corpus/nx adiposum/nx
脂肪/n 体/ng
corpus/nx callosum/nx
胼胝/n 体/j
corpus/nx delicti/nx [/w di5liktai/nx ]/w
【/w 律/vg 】/w 犯罪/vn 事实/n ;/w (/w 谋杀案/n 中/f 的/u )/w 被/p 杀/v 尸体/n

corpus/nx juris/nx
[/w 5dVuEris/nx ]/w
法令/n 大全/n ,/w 法典/n corpus/nx luteum/nx 【/w 解/v 】/w 黄/a 体/ng corpus/nx striatum/nx 【/w 解/v 】/w 纹/ng 状/ng 体/ng

actual/nx corpus/nx
实际/a 财产/n 主体/n (/w 如/v 区别/n 于/p 利息/n 的/u 本金/n )/w
estate/nx corpus/nx
遗产/n 本/r 值/v
habeas/nx corpus/nx
[/w 5heibjEs5kC:/nx pEs/nx ]/w
人/n 身/ng 保护/v 权/n
trust/nx corpus/nx
信托/b 资产/n 本/r 值/v

corpus/nx
[/w 5kC:/nx pEs/nx ]/w
n./nx 尸体/n ,/w 文集/n ,/w (/w 某/r 项/q 基金/n 的/u )/w 本金/n
 
回复:如何去除中英混合文本中的中文或英文?

分割后得到的中文部分(CHIN_OUT.txt):

[rps]
[]
[]


[r-]

,,


[rps]
[]
[]


【复数】
[r-]

丛书某一特种的或有关某一主题的大型系列文献
,,
资金基金或资产的本金或资本,以区别于利息或收入

【解剖学】

主体身体结构或器官的主要部分

器官具有某一功能的明显的身体部位或器官

【音乐】

小提琴的总长


中古英语

源自拉丁语

[]

文集,全集


[]

([])
身体
[谑]躯体,尸体
文献,文集,大全
(事物的)主体
本金
【解】(脂肪┨澹弧局病吭?

脂肪体

胼胝体
[]
【律】犯罪事实;(谋杀案中的)被杀尸体


[]
法令大全,法典【解】黄体【解】纹状体


实际财产主体(如区别于利息的本金)

遗产本值

[]
人身保护权

信托资产本值


[]
尸体,文集,(某项基金的)本金
 
Back
顶部