Genereate a histogram of how many times each unique word is used in that test
来源:互联网 发布:哈曼卡顿和惠威 知乎 编辑:程序博客网 时间:2024/05/22 13:17
#! /usr/bin/expect --
# Genereate a histogram of how many times each unique word is used in that test.
proc hWord {sText} {
set debug 0
# Print the primary string text
if {$debug == 1} {
send_user "The text is $sText\n"
}
# Backup the string text
set bText $sText
# Copy the unique word into a list
set sList ""
for {set i 0} {$i < [llength $sText]} {incr i} {
set sTmp [lindex $sText $i]
if {[lsearch $sList $sTmp] == -1} {
lappend sList $sTmp
}
}
if {$debug == 1} {
send_user "The list with unique word is $sList\n"
}
# Assign the default counter value of different unique word
for {set i 0} {$i < [llength $sList]} {incr i} {
set cValue($i) 0
}
# Do the unique word counter
for {set i 0} {$i < [llength $sList]} {incr i} {
set sTmp [lindex $sList $i]
set cTmp [lsearch -all $sText $sTmp]
set cValue($i) [llength $cTmp]
}
# Print the unique word counter
puts [format "%-10s %-10s" "Word" "Times"]
for {set i 0} {$i < [llength $sList]} {incr i} {
set sTmp [lindex $sList $i]
puts [format "%-10s %-10d" $sTmp $cValue($i)]
}
return
}
set sText [lindex $argv 0]
if {$sText == ""} {
puts "Please input string with multi words, (eg, nihao nihao 123)"
exit
} else {
hWord $sText
}
# Genereate a histogram of how many times each unique word is used in that test.
proc hWord {sText} {
set debug 0
# Print the primary string text
if {$debug == 1} {
send_user "The text is $sText\n"
}
# Backup the string text
set bText $sText
# Copy the unique word into a list
set sList ""
for {set i 0} {$i < [llength $sText]} {incr i} {
set sTmp [lindex $sText $i]
if {[lsearch $sList $sTmp] == -1} {
lappend sList $sTmp
}
}
if {$debug == 1} {
send_user "The list with unique word is $sList\n"
}
# Assign the default counter value of different unique word
for {set i 0} {$i < [llength $sList]} {incr i} {
set cValue($i) 0
}
# Do the unique word counter
for {set i 0} {$i < [llength $sList]} {incr i} {
set sTmp [lindex $sList $i]
set cTmp [lsearch -all $sText $sTmp]
set cValue($i) [llength $cTmp]
}
# Print the unique word counter
puts [format "%-10s %-10s" "Word" "Times"]
for {set i 0} {$i < [llength $sList]} {incr i} {
set sTmp [lindex $sList $i]
puts [format "%-10s %-10d" $sTmp $cValue($i)]
}
return
}
set sText [lindex $argv 0]
if {$sText == ""} {
puts "Please input string with multi words, (eg, nihao nihao 123)"
exit
} else {
hWord $sText
}
0 0
- Genereate a histogram of how many times each unique word is used in that test
- openmp--test how many threads used
- 'WHERE' is the same of 'on' in mysql(many times,but not always)
- How many times
- How many types of vmware product and what is difference between each other?
- How to: Determine if a Package that is About to be Compiled is Being Used Currently (文档 ID 1054939.6
- Did you know that each integer in a PHP array takes 68 bytes of storage?
- How is jstack being used to find the bottlenect of a java program
- How many permissions used in the famous IM app?
- How to move the databases that are used by SharePoint Portal Server 2003 to a computer that is running SQL Server
- Finding a number that repeats even no of times where all the other numbers repeat odd no of times
- How do I close a single buffer (out of many) in Vim?
- How to find child controls that are located in the template of a parent control
- HDU 3561 How many times 【计算几何】
- How is i_is_deleted attribute used in version tree?
- How to sort by a form that is not displayed in the document in MicroStrategy Desktop 8.x
- how to make a transparent histogram in matlab
- How to call a closure that is a class variable?
- poj-2318-TOYS-计算几何
- 500G的硬盘坏了怎么找回文件
- Java面向对象之继承
- 手动生成AWR报告
- 线程之路一:CreateThread()和-beginthreadex()
- Genereate a histogram of how many times each unique word is used in that test
- 在 Android* 平台上设置原生 OpenGL ES*
- pentaho5.0.1将数据库移植成mysql
- AD域帐号被锁问题排查
- <include />&<merge />
- 为Junit虚拟Jsp Container的数据库连接池
- 傅老师课堂:Oracle高级查询之GROUP BY
- MD5 java 学习笔记01
- 差异化比较数据结构