当前位置:编程学习 > JAVA >>

sim相似性检查

SIM(1) Vrije Universiteit SIM(1)
NAME
sim - find similarities in C, Java, Pascal, Modula-2, Lisp, Miranda or text files
SYNOPSIS
sim_c [ -[defFinpsST] -r N -t N -w N -o F ] file ... [ / [ file ... ] ]
sim_c ...
sim_java ...
sim_pasc ...
sim_m2 ...
sim_lisp ...
sim_mira ...
sim_text ...
DESCRIPTION
Sim_c reads the C files file ... and looks for pieces of text that are similar; two pieces of program text
are similar if they only differ in layout, comment, identifiers and the contents of numbers, strings and
characters. If any runs of sufficient length are found, they are reported on standard output; the number
of significant tokens in the run is given between square brackets.
Sim_java does the same for Java, sim_pasc for Pascal, sim_m2 for Modula-2, sim_lisp for Lisp, and
sim_mira for Miranda. Sim_text works on arbitrary text; it is occasionally useful on shell scripts.
The program can be used for finding copied pieces of code in purportedly unrelated programs (with -s
or -S), or for finding accidentally duplicated code in larger projects (with -f).
If a / is present between the input files, the latter are divided into a group of "new" files (before the /)
and a group of "old" files; if there is no /, all files are "new". Old files are never compared to each
other. Since the similarity tester reads the files several times, it cannot read from standard input. (See,
however, the -i option.)
There are the following options:
-d The output is in a diff(1)-like format instead of the default 2-column format.
-e Each file is compared to each file in isolation; this will find all similarities between all texts
involved, regardless of duplicates.
-f Runs are restricted to pieces with balancing parentheses, to isolate potential functions (C,
Java, Pascal, Modula-2 and Lisp only).
-F The names of functions in calls are required to match exactly (C, Java, Pascal, Modula-2 and
Lisp only).
-i The names of the files to be compared are read from standard input, including a possible / ; the
file names need to be separated by layout. This allows a very large number of file names to be
specified; it differs from the @ facility provided by some compilers in that it handles file
names only, and does not recognize option arguments.
-n Similarities found are only summarized, not displayed.
-o F The output is written to the file named F.
-p The output is given in similarity percentages; see below.
-r N The minimum run length is set to N (default is N = 24).
-s The contents of a file are not compared to itself (-s for "not self").
-S The contents of the new files are compared to the old files only - not between themselves.
-t N In combination with the -p option, sets the threshold (in percents) below which similarities
will not be reported.
-T A more terse and uniform form of output is produced, which may be more suitable for postprocessing.
Page 1 (2001/11/13) September 23, 2008
SIM(1) Vrije Universiteit SIM(1)
-w N The page width used is set to N columns (default is N = 80).
The -p option results in lines of the form F consists for x % of G material meaning
that x % of F’s text can also be found in G. Note that this relation is not symmetric; it is in fact quite
possible for one file to consist for 100 % of text from another file, while the other file consists for only
1 % of text of the first file, if their lengths differ enough. A threshold can be set using the -T option.
Note also that the granularity of the recognized text is still governed by the -r option or its default.
Care has been taken to keep all internal processes linear in the length of the input, with the exception of
the matching process which is almost linear, using a hash table; various other tables are used for
speed-up. If, however, there is not enough memory for the tables, they are discarded in order of unimportance,
under which conditions the algorithms revert to their quadratic nature.
AUTHOR
Dick Grune, Vrije Universiteit, Amsterdam.
BUGS
Strong periodicity in the input text (like a table of N almost identical lines) causes problems. Sim tries
to cope with this but cannot avoid giving appr. log N messages about it. The best advice is still to take
the offending files out of the game.
Since it uses lex(1) on some systems, it may dump core on any weird construction that overflows lex’s
internal buffers.
September 23, 2008 (2001/11/13) Page 2 --------------------编程问答-------------------- SIM卡(1)Vrije大学SIM卡(1)
名称
SIM卡 - 找到了C,Java,Pascal中,Modula-2的,Lisp中,米兰达或文本文件的相似性
内容简介
sim_c [ - [defFinpsST]-R N-T N-W N-O F],文件... [/ [文件... ]]
sim_c ...
sim_java ...
sim_pasc ...
sim_m2 ...
sim_lisp ...
sim_mira ...
sim_text ...
描述
sim_c读取C文件文件...寻找类似的文本;两件程序文本
如果他们只在不同的布局,注释,标识符和内容的数字,字符串和类似
字符。如果发现任何足够长的运行,他们在标准输出上报告的数量
在运行中的重大令牌方括号内。
sim_java为Java,为帕斯卡sim_pasc,sim_m2 Modula-2的,sim_lisp Lisp的,
sim_mira米兰达。 sim_text任意文本;是偶尔有用的shell脚本。
该方案可以用于寻找据称无关的程序代码的复制件(与-s
或-S),或寻找意外地在较大的项目中重复代码(-F)。
如果A /本之间的输入文件,后者是一个“新”的文件组(前/分为)
和一群“老”的文件,如果没有/,所有文件都是“新”。从来没有比每个旧文件
其他。自相似性测试仪读取的文件多次,它不能从标准输入读取。 (见
然而,-i选项。)
有以下选项:
-D的输出是在2列的格式,而不是默认的差异(1)样的格式。
-E每个文件相比,每个隔离的文件,这之间的所有文本会发现所有的相似之处
参与,不论重复。
-F运行的制约与平衡括号件,隔离潜在的功能(丙,
爪哇,帕斯卡尔,Modula-2的和Lisp)。
- F调用的函数的名称必须完全匹配(爪哇,帕斯卡尔,Modula-2和
Lisp的唯一)。
我的文件的名称进行比较阅读,包括可能的/从标准输入;
文件名需要被分开布局。这允许一个文件名是非常大的数目
指定它不同于一些编译器处理文件,它提供的@设施
其名,和不认识的选项参数。
-N的异同发现,只有总结,不显示。
-O上输出写入到文件名为楼
-P的输出给出了相似的百分比;见下文。
-R n的最低运行长度设置为N(默认为N = 24)。
-S文件的内容本身相比(-S“自我”)。
-S的新文件的内容相比,只有旧的文件 - 而不是彼此之间。
-T-p选项的组合氮,设置阈值(百分比)低于该相似之处
不会被报道。
- TA更简洁和统一输出的形式产生,这可能是更合适的后处理。
第1页(2001年11月13日),2008年9月23日
SIM卡(1)Vrije大学SIM卡(1)
W N使用的页面宽度设置为N列(默认是n = 80)。
-p的形式F行的选项结果为x%G的实质意义
X%F的文字,也可以在G中注意发现,这种关系不是对称的,它实际上是相当
一个文件可能包含从另一个文件中的文本为100%,而其他文件包括只
1%的第一个文件的文本,如果它们的长度不同足够。使用-T选项,可以设定一个阈值。
还要注意识别文本的粒度仍然-r选项,其默认管辖。
已经采取谨慎措施,以保持在所有内部流程的线性输入的长度,异常
匹配的过程几乎是线性的,使用一个哈希表;用于其他各种表
速度。然而,如果有足够的内存表,为了敢为天下先,他们被丢弃
在何种情况下该算法恢复其二次本质。
香港
迪克Grune,阿姆斯特丹Vrije大学。
臭虫
在输入文字(像表N几乎相同的线条)的强周期性导致问题。 SIM尝试
应付这个,但不能避免给APPR。记录列印消息。最好的建议仍是采取
出局的违规文件。
由于它使用法(1)在某些系统上,它可能会倾倒溢出法的任何奇怪的建设的核心
内部缓冲区。
9月23日,2008(2001年11月13日)第2页 --------------------编程问答-------------------- 不知道你写的是什么!
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,