去掉Word中的所有汉字或英文

快捷键“CTRL+H”


去掉汉字

查找内容填:[一-龥]

替换为:空格

勾上使用通配符

全部替换即可。



去掉英文

查找内容填:^$

替换为:空格

不勾使用通配符

全部替换即可。


以下是一个使用C语言实现去除txt文件文或英文停用词的程序例子: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> // 停用词表(文) char *stop_words_cn[] = {"的", "了", "在", "是", "和", "就", "都", "而", "及", "与", "也", "等", "要", "这", "那", "之", "吧", "呢", "啊", NULL}; // 停用词表(英文) char *stop_words_en[] = {"a", "an", "the", "and", "but", "or", "in", "on", "at", "to", "with", "from", "of", "for", "by", "about", "as", NULL}; // 判断一个字符是否为文字符 int is_chinese_char(unsigned char c) { return (c >= 0x4e00 && c <= 0x9fa5); } // 判断一个字符是否为英文字符 int is_english_char(unsigned char c) { return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); } // 判断一个字符串是否为文停用词 int is_stop_word_cn(char *word) { int i = 0; while (stop_words_cn[i] != NULL) { if (strcmp(word, stop_words_cn[i]) == 0) { return 1; } i++; } return 0; } // 判断一个字符串是否为英文停用词 int is_stop_word_en(char *word) { int i = 0; while (stop_words_en[i] != NULL) { if (strcmp(word, stop_words_en[i]) == 0) { return 1; } i++; } return 0; } int main(int argc, char *argv[]) { if (argc < 3) { printf("Usage: %s <input_file> <output_file>\n", argv[0]); return 1; } FILE *input_file = fopen(argv[1], "r"); if (input_file == NULL) { printf("Failed to open input file: %s\n", argv[1]); return 1; } FILE *output_file = fopen(argv[2], "w"); if (output_file == NULL) { printf("Failed to open output file: %s\n", argv[2]); return 1; } char word[256]; int is_in_word = 0; // 是否正在处理一个单词 while (!feof(input_file)) { unsigned char c = fgetc(input_file); if (is_chinese_char(c) || is_english_char(c)) { // 如果遇到文或英文字符,将其加入单词缓存 word[strlen(word)] = c; is_in_word = 1; } else { if (is_in_word) { // 如果当前正在处理一个单词,判断该单词是否为停用词 word[strlen(word)] = '\0'; if (!is_stop_word_cn(word) && !is_stop_word_en(word)) { // 如果不是停用词,将该单词写入输出文件 fputs(word, output_file); } // 清空单词缓存 word[0] = '\0'; is_in_word = 0; } // 如果遇到非文或英文字符,将其写入输出文件 fputc(c, output_file); } } fclose(input_file); fclose(output_file); return 0; } ``` 该程序将从命令行接收两个参数:输入文件名和输出文件名。程序会按照一定规则读取输入文件的内容,并将去除停用词后的内容写入输出文件。程序使用了一个文停用词表和一个英文停用词表,可以根据需要进行修改。程序的停用词表只列举了部分常用的停用词,如果需要更全面的停用词表可以从互联网上搜索并自行添加。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

【ql君】qlexcel

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值