首页 文章 精选 留言 我的

精选列表

搜索[文本编辑器],共10000篇文章
优秀的个人博客,低调大师

sklearn.feature_extraction.text.CountVectorizer提取文本特征,将文档词块化

sklearn.feature_extraction.text. CountVectorizer ( input=u'content' , encoding=u'utf-8' , decode_error=u'strict' , strip_accents=None , lowercase=True , preprocessor=None , tokenizer=None , stop_words=None , token_pattern=u'(? u)\b\w\w+\b' , ngram_range=(1 , 1) , analyzer=u'word' , max_df=1.0 , min_df=1 , max_features=None , vocabulary=None , binary=False , dtype=<type 'numpy.int64'> ) 作用:Convert a collection of text documents to a matrix of token counts(计算词汇的数量,即tf);结果由scipy.sparse.coo_matrix进行稀疏表示。 看下参数就知道CountVectorizer在提取tf时都做了什么: strip_accents : {‘ascii’, ‘unicode’, None}:是否除去“音调”,不知道什么是“音调”?看:http://textmechanic.com/?reqp=1&reqr=nzcdYz9hqaSbYaOvrt== lowercase : boolean, True by default:计算tf前,先将所有字符转化为小写。 这个参数一般为True。 preprocessor : callable or None (default):复写thepreprocessing (string transformation) stage,但保留tokenizing and n-grams generation steps. 这个参数可以自己写。 tokenizer : callable or None (default):复写the string tokenization step,但保留preprocessingand n-grams generation steps. 这个参数可以自己写。 stop_words : string {‘english’}, list, or None (default):如果是‘english’, a built-in stop word list for English is used。如果是a list,那么最终的tokens中将去掉list中的所有的stop word。如果是None, 不处理停顿词;但 参数 max_df 可以设置为 [0.7, 1.0) 之间,进而根据 intra corpus document frequency(df) of terms自动detect and filter stop words。这个参数要根据自己的需求调整。 token_pattern : string:正则表达式,默认筛选长度大于等于2的字母和数字混合字符(select tokens of 2 or more alphanumeric characters),参数analyzer设置为word时才有效。 ngram_range : tuple (min_n, max_n):n-values值得上下界,默认是 ngram_range=(1 , 1), 该范围之内的n元feature都会被提取出来! 这个参数要根据自己的需求调整。 analyzer : string, {‘word’, ‘char’, ‘char_wb’} or callable:特征基于wordn-grams还是character n-grams。如果是callable是自己复写的从the raw, unprocessed input提取特征的函数。 max_df : float in range [0.0, 1.0] or int, default=1.0: min_df : float in range [0.0, 1.0] or int, default=1:按比例,或绝对数量删除df超过max_df或者df小于min_df的word tokens。有效的前提是参数vocabulary设置成Node。 max_features : int or None, default=None:选择tf最大的max_features个特征。有效的前提是参数vocabulary设置成Node。 vocabulary : Mapping or iterable, optional:自定义的特征word tokens,如果不是None,则只计算vocabulary中的词的tf。 还是设为None靠谱。 binary : boolean, default=False:如果是True,tf的值只有0和1,表示出现和不出现,useful for discrete probabilistic models that model binary events rather than integer counts.。 dtype : type, optional:Type of the matrix returned by fit_transform() or transform().。

优秀的个人博客,低调大师

Linux高级文本处理之gawk变量的操作符(三)

一、变量 Awk 变量以字母开头,后续字符可以是数字、字母、或下划线。关键字不能用作 awk 变量。awk 变量可以直接使用而不需事先声明。 如果要初始化变量,最好在BEGIN 区域内做,它只会执行一次。Awk 中没有数据类型的概念,一个 awk 变量是 number 还是 string 取决于该变量所处的上下文。 实例1:使用”total”便是用户建立的用来存储公司所有雇员工资总和的变量。 [root@localhost~]#catemp4 101,JohnDoe,CEO,10000 102,JasonSmith,ITManager,5000 103,RajReddy,Sysadmin,4500 104,AnandRam,Developer,4500 105,JaneMiller,SalesManager,3000 [root@localhost~]#catemp.awk BEGIN{ FS=","; total=0; } { print$2"'ssalaryis:"$4; total=total+$4; } END{ print"---\nTotalcompanysalary=$"total; } [root@localhost~]#awk-femp.awkemp4 JohnDoe'ssalaryis:10000 JasonSmith'ssalaryis:5000 RajReddy'ssalaryis:4500 AnandRam'ssalaryis:4500 JaneMiller'ssalaryis:3000 --- Totalcompanysalary=$27000 awk自定义变量的方法: 1.借助-v选项,可以将外部值(并非来自stdin)传递给awk 实例2: [root@localhost~]#awk-vvar="young"'BEGIN{printvar,"\n","---"}{printvar}'./num young --- young young young 2.通过VAR=value的方式定义 实例3: [root@localhost~]#awk'{printv1,v2}'v1="young"v2="geek"./num younggeek younggeek younggeek 二、一元操作符 1.取正取反 只接受单个操作数的操作符叫做一元操作符。 实例1:取反操作 [root@localhost~]#catemp4 101,JohnDoe,CEO,10000 102,JasonSmith,ITManager,5000 103,RajReddy,Sysadmin,4500 104,AnandRam,Developer,4500 105,JaneMiller,SalesManager,3000 [root@localhost~]#awk-F,'{print-$4}'emp4 -10000 -5000 -4500 -4500 -3000 注意:取反只对数值类数据生效,字符串取反结果全部为0. 实例2: [root@localhost~]#catnum -1 -2 -3 [root@localhost~]#awk'{print+$1}'num -1 -2 -3 [root@localhost~]#awk'{print-$1}'num 1 2 3 2.自增自减 VAR1=++VAR或者VAR1=--VAR,表示VAR先增加或者减去1再赋值给VAR1,VAR1=VAR++或VAR1=VAR--,表示先将VAR赋值给VAR1,VAR再增减或者减去1. 实例1:前自加子减 [root@localhost~]#awk-F,'{print++$4}'emp4#前自加 10001 5001 4501 4501 3001 [root@localhost~]#awk-F,'{print--$4}'emp4#前自减 9999 4999 4499 4499 实例2:后自加子减 [root@localhost~]#awk-F,'{$4--;print$4}'emp4#后自减 9999 4999 4499 4499 2999 [root@localhost~]#awk-F,'{$4++;print$4}'emp4#后自加 10001 5001 4501 4501 3001 实例3:打印所有可登陆 shell 的用户总数: [root@localhost~]#awk-F':' >'$NF~/\/bin\/bash/{n++} >END{printn}'/etc/passwd 10 [root@localhost~]#grep-c'/bin/bash$'/etc/passwd 10 实例4: [root@localhost~]#catnum 1 2 1 1 3 4 2 [root@localhost~]#awk'/1/{printNF}'num 1 1 1 [root@localhost~]#awk'/1/{n++}END{printn}'num 3 [root@localhost~]#awk'/2/{n++}END{printn}'num 2 [root@localhost~]#awk'/3/{n++}END{printn}'num 1 [root@localhost~]#awk'/4/{n++}END{printn}'num 1 三、算术运算符 需要两个操作数的操作符,成为二元操作符。 Awk 中有多种基本二元操作符(如算术操作符、 字符串操作符、赋值操作符,等等)。 实例1:将每件单独的商品价格减少 20% 并且将每件单独的商品的数量减少 1 [root@localhost~]#catitems.txt 101,HDCamcorder,Video,210,10 102,Refrigerator,Appliance,850,2 103,MP3Player,Audio,270,15 104,TennisRacket,Sports,190,20 105,LaserPrinter,Office,475,5 [root@localhost~]#catdis.awk BEGIN{ FS=","; OFS=","; discount=0 } { discount=$4*20/100; print$1,$2,$3,$4-discount,$5-1 } [root@localhost~]#awk-fdis.awkitems.txt 101,HDCamcorder,Video,168,9 102,Refrigerator,Appliance,680,1 103,MP3Player,Audio,216,14 104,TennisRacket,Sports,152,19 105,LaserPrinter,Office,380,4 实例2:只打印偶数行 [root@localhost~]#awk'NR%2==0'items.txt 102,Refrigerator,Appliance,850,2 104,TennisRacket,Sports,190,20 四、字符串操作符 (空格)是连接字符串的操作符。 实例1: [root@localhost~]#catstr.awk BEGIN{ FS=","; OFS=","; str1="Audio"; str2="Video"; nustr="100"; str3=str1str2; print"Concatenatestringis:"str3; nustr=nustr+1; print"Strtonu:"nustr; } [root@localhost~]#awk-fstr.awkitems.txt Concatenatestringis:AudioVideo Strtonu:101 四、赋值操作符 实例1: [root@localhost~]#catfz.awk BEGIN{ FS=","; OFS=","; total1=total2=total3=total4=total5=10; total1+=5;printtotal1; total2-=5;printtotal2; total3*=5;printtotal3; total4/=5;printtotal4; total5%=5;printtotal5; } [root@localhost~]#awk-ffz.awkitems.txt 15 5 50 2 0 实例2:打印商品清单 [root@localhost~]#catitems.txt 101,HDCamcorder,Video,210,10 102,Refrigerator,Appliance,850,2 103,MP3Player,Audio,270,15 104,TennisRacket,Sports,190,20 105,LaserPrinter,Office,475,5 [root@localhost~]#awk-F,' >BEGIN{total=0}{total+=$5} >END{print"TotalQutantity:"total}'items.txt TotalQutantity:52 五、比较操作符 实例1:打印数量小于等于临界值 5 的商品信息 [root@localhost~]#awk-F,'$5<=5'items.txt 102,Refrigerator,Appliance,850,2 105,LaserPrinter,Office,475,5 实例2:打印编号为 103 的商品信息 [root@localhost~]#awk-F,'$1==103'items.txt 103,MP3Player,Audio,270,15 实例3:打印除 Video 以外的所有商品 [root@localhost~]#awk-F,'$3!="Video"'items.txt 102,Refrigerator,Appliance,850,2 103,MP3Player,Audio,270,15 104,TennisRacket,Sports,190,20 105,LaserPrinter,Office,475,5 实例4:同实例3,但只打印描述信息 [root@localhost~]#awk-F,'$3!="Video"{print$2}'items.txt Refrigerator MP3Player TennisRacket LaserPrinter 实例5:打印价钱低于 900 或者数量小于等于临界值 5 的商品信息 [root@localhost~]#awk-F,'$5<=5||$4<900'items.txt 101,HDCamcorder,Video,210,10 102,Refrigerator,Appliance,850,2 103,MP3Player,Audio,270,15 104,TennisRacket,Sports,190,20 105,LaserPrinter,Office,475,5 实例6:打印/etc/password 中最大的 UID(以及其所在的整行)。 [root@localhost~]#awk-F':'' >$3>maxuid >{maxuid=$3;maxline=$0} >END{printmaxuid,maxline}'/etc/passwd 1009user3:x:1009:1010::/home/user3:/bin/bash 实例8:打印/etc/passwd 中 UID 和 GROUP ID 相同的用户信息 [root@localhost~]#awk-F':''$3==$4'/etc/passwd root:x:0:0:young,geek,010110110,0101101101:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin dbus:x:81:81:Systemmessagebus:/:/sbin/nologin vcsa:x:69:69:virtualconsolememoryowner:/dev:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin 实例9:打印/etc/passwd 中 UID >= 100 并且用户的 shell 是/bin/sh 的用户 [root@localhost~]#awk-F:'$3>=100&&$7=="/bin/sh"'/etc/passwd user1:x:800:800:testuser:/none:/bin/sh 或者: [root@localhost~]#awk-F':''$3>=100&&$NF~/\/bin\/sh/'/etc/passwd user1:x:800:800:testuser:/none:/bin/sh#正则表达式模式匹配 实例10:打印/etc/passwd 中没有注释信息(第 5 个字段)的用户 [root@localhost~]#awk-F:'$5==""'/etc/passwd abrt:x:173:173::/etc/abrt:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin sys:x:498:1001::/home/sys:/bin/bash natasha:x:1006:1007::/home/natasha:/bin/bash harry:x:1007:1008::/home/harry:/bin/bash sarah:x:497:497::/home/sarah:/bin/nologin 实例11:使用取反(!)运算符打印奇数行 [root@localhost~]#seq10|awk'i=!i' 1 3 5 7 9 实例12:打印偶数行 [root@localhost~]#seq10|awk-vi=1'i=!i' 2 4 6 8 10 六、正则表达式操作符 实例1: [root@localhost~]#catitems.txt 101,HDCamcorder,Video,210,10 102,Refrigerator,Appliance,850,2 103,MP3Player,Audio,270,15 104,TennisRacket,Sports,190,20 105,LaserPrinter,Office,475,5 [root@localhost~]#awk-F,'$2=="Tennis"'items.txt#精确匹配 [root@localhost~]#awk-F,'$2~"Tennis"'items.txt#模糊匹配 104,TennisRacket,Sports,190,20 实例2: [root@localhost~]#awk-F,'$2!~"Tennis"'items.txt#不匹配 101,HDCamcorder,Video,210,10 102,Refrigerator,Appliance,850,2 103,MP3Player,Audio,270,15 105,LaserPrinter,Office,475,5 实例3:打印 shell 为/bin/bash 的用户的总数,如果最后一个字段包含”/bin/bash”,则变量n 增加 1 [root@localhost~]#grep-c'/bin/bash'/etc/passwd 9 [root@localhost~]#awk-F:'$NF~/\/bin\/bash/{n++}END{printn}'/etc/passwd 9 补充说明: awk PATTERN模式的其他形式: empy:空模式,匹配所有行 关系表达式,表达式结果非0为真,则执行后面body中语句;0则为假,不执行。例如 awk-F:'$3>=500{print$1,$3}'/etc/passwd 3.行范围,类似sed或vim中的地址定界: /startpattern/,/endpattern/ 注意:不支持直接给出数字格式 实例: [root@localhost~]#awk'/^root/,/^mail/{print$0}'/etc/passwd root:x:0:0:young,geek,010110110,0101101101:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin

优秀的个人博客,低调大师

这款插件让你在开源图像编辑器 GIMP 中体验谷歌 Nano Banana

开发者 Josh Ellithorpe 近日发布Dream Prompter 开源插件,将谷歌最新的 Gemini 2.5 Flash Image Preview 模型(代号 “Nano Banana”)引入 GIMP。 该插件支持用户在 GIMP 内直接通过文字提示生成新图像,或对现有图像进行自然语言编辑,无需切换到外部工具。使用 Dream Prompter 需绑定启用计费的 Google Gemini API key,插件本身已开源并托管在 GitHub。 Ellithorpe 表示,他在 Claude 模型的帮助下快速完成了插件开发。这一集成让 GIMP 用户能够在开源环境中享受与 Adobe 等商业软件类似的 AI 创作体验。

优秀的个人博客,低调大师

墨干编辑器 V1.1.4: OSPP 开源之夏 7 月成果

修复了V1.1.3的两个严重问题,从1.2.0开发分支向后移植了张佳在OSPP开源之夏7月完成的三个绘图工具相关的改进 重要变更​ 修复:修复了V1.1.3引入的部分插件无法使用的问题 修复:修复了V1.1.3引入的绘图工具无法正常使用的问题 绘图:在绘图模式中,使用Shift+鼠标左键等价于鼠标右键,以方便触摸板用户 绘图:粘贴一个对象时,会在原来的位置上做一个小的位移,以便于区分 绘图:进入移动模式时,光标变成小手的形状,按下鼠标左键抓取一个对象进行移动时,光标会变成闭合的小手形状 编辑:macOS和Windows快捷键改回相应的快捷键风格,Linux平台仍旧默认采用Emacs风格快捷键

优秀的个人博客,低调大师

开源图形编辑器 GIMP 被恶意软件“劫持”搜索引擎结果

有网友发现,当他使用 Google 搜索开源图像编辑软件 "GIMP" 时,搜索引擎返回的第一条结果是包含广告标记的「GIMP.org」官网。但点击该广告却进入了伪装成 GIMP 的钓鱼网站,而不是真正的官网,它提供下载的是伪装成 GIMP 的 700MB 可执行文件——实际上是恶意软件。 钓鱼网站的域名是gilimp.org,与真正的官网域名 gimp.org存在明显区别。BleepingCompuer 还发现了与此活动相关的另一个域名 gimp.monster,并调查了这些网站托管的恶意软件样本,发现它是名为 VIDAR 的信息窃取木马,被设计用于窃取浏览器上储存的密码、cookies、历史和信用卡数据,文件传输应用信息,以及加密货币钱包,Telegram 登陆凭证,等等。 ▲ 有问题的 Google 广告将访问者引导至伪装成 GIMP 的钓鱼网站 ▲ 虚假的 GIMP 官网 'gilimp.org' 让人感到疑惑的是,为什么 Google 搜索引擎的结果显示了真正的"GIMP.org"域名,但点击后进入的目标域名却是虚假的"gilimp.org"网站。 按照 Google 广告的发布政策,在搜索引擎结果中显示的 URL (display URL) 不需要与实际访问的 URL (landing URL) 保持一致。也就是说Google 允许广告主使用两个不同的 URL 来创建广告:一个是显示在搜索引擎结果中的 URL,另一个是用户实际访问的最终 URL。 虽然两者不必相同,但谷歌对于display URL的允许内容有严格的政策,并且这些政策要求需要使用与landing URL相同的主域名。 对于 GIMP 这个案例,BleepingComputer 已联系 Google 求证 Google Ad Manager 是否存在允许恶意广告的潜在错误,目前尚未收到答复。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册