Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
2214a039
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2214a039
编写于
5月 09, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add hb-diff-ngrams
上级
178e6dce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
5 deletion
+72
-5
test/shaping/Makefile.am
test/shaping/Makefile.am
+1
-0
test/shaping/hb-diff-ngrams
test/shaping/hb-diff-ngrams
+5
-0
test/shaping/hb_test_tools.py
test/shaping/hb_test_tools.py
+66
-5
未找到文件。
test/shaping/Makefile.am
浏览文件 @
2214a039
...
...
@@ -13,6 +13,7 @@ EXTRA_DIST += \
hb-diff
\
hb-diff-colorize
\
hb-diff-filter-failures
\
hb-diff-ngrams
\
hb-diff-stat
\
hb-manifest-read
\
hb-manifest-update
\
...
...
test/shaping/hb-diff-ngrams
0 → 100755
浏览文件 @
2214a039
#!/usr/bin/python
from
hb_test_tools
import
*
UtilMains
.
process_multiple_files
(
DiffSinks
.
print_ngrams
)
test/shaping/hb_test_tools.py
浏览文件 @
2214a039
...
...
@@ -155,12 +155,60 @@ class DiffFilters:
if
not
DiffHelpers
.
test_passed
(
lines
):
for
l
in
lines
:
yield
l
class
Stat
:
def
__init__
(
self
):
self
.
count
=
0
self
.
freq
=
0
def
add
(
self
,
test
):
self
.
count
+=
1
self
.
freq
+=
test
.
freq
class
Stats
:
def
__init__
(
self
):
self
.
passed
=
Stat
()
self
.
failed
=
Stat
()
self
.
total
=
Stat
()
def
add
(
self
,
test
):
self
.
total
.
add
(
test
)
if
test
.
passed
:
self
.
passed
.
add
(
test
)
else
:
self
.
failed
.
add
(
test
)
def
mean
(
self
):
return
float
(
self
.
passed
.
count
)
/
self
.
total
.
count
def
variance
(
self
):
return
(
float
(
self
.
passed
.
count
)
/
self
.
total
.
count
)
*
\
(
float
(
self
.
failed
.
count
)
/
self
.
total
.
count
)
def
stddev
(
self
):
return
self
.
variance
()
**
.
5
def
zscore
(
self
,
population
):
"""Calculate the standard score.
Population is the Stats for population.
Self is Stats for sample.
Returns larger absolute value if sample is highly unlikely to be random.
Anything outside of -3..+3 is very unlikely to be random.
See: http://en.wikipedia.org/wiki/Standard_score"""
return
(
self
.
mean
()
-
population
.
mean
())
/
population
.
stddev
()
class
DiffSinks
:
@
staticmethod
def
print_stat
(
f
):
passed
=
0
failed
=
0
# XXX port to Stats, but that would really slow us down here
for
key
,
lines
in
DiffHelpers
.
separate_test_cases
(
f
):
if
DiffHelpers
.
test_passed
(
lines
):
passed
+=
1
...
...
@@ -172,21 +220,34 @@ class DiffSinks:
@
staticmethod
def
print_ngrams
(
f
,
ns
=
(
1
,
2
,
3
)):
gens
=
tuple
(
Ngram
.
generator
(
n
)
for
n
in
ns
)
allstats
=
Stats
()
allgrams
=
{}
for
key
,
lines
in
DiffHelpers
.
separate_test_cases
(
f
):
test
=
Test
(
lines
)
unicodes
=
test
.
unicodes
del
test
allstats
.
add
(
test
)
for
gen
in
gens
:
print
"Printing %d-grams:"
%
gen
.
n
for
ngram
in
gen
(
unicodes
):
print
ngram
for
ngram
in
gen
(
test
.
unicodes
):
if
ngram
not
in
allgrams
:
allgrams
[
ngram
]
=
Stats
()
allgrams
[
ngram
].
add
(
test
)
importantgrams
=
{}
for
ngram
,
stats
in
allgrams
.
iteritems
():
if
stats
.
failed
.
count
>=
30
:
# for statistical reasons
importantgrams
[
ngram
]
=
stats
allgrams
=
importantgrams
del
importantgrams
for
ngram
,
stats
in
allgrams
.
iteritems
():
print
"zscore: %9f failed: %6d passed: %6d ngram: <%s>"
%
(
stats
.
zscore
(
allstats
),
stats
.
failed
.
count
,
stats
.
passed
.
count
,
','
.
join
(
"U+%04X"
%
u
for
u
in
ngram
))
class
Test
:
def
__init__
(
self
,
lines
):
self
.
freq
=
1
self
.
passed
=
True
self
.
identifier
=
None
self
.
text
=
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录