Skip to content

Commit eeb180d

Browse files
⚡️ 💫 Benchmark with blingfire
1 parent 8fc9e71 commit eeb180d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

benchmarks/blingfire_benchmark.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import blingfire
2+
from blingfire import text_to_sentences
3+
4+
from .english_golden_rules import GOLDEN_EN_RULES
5+
6+
def blingfire_english_benchmark(golden_rules):
7+
global percent_score
8+
total_rules = len(golden_rules)
9+
score = 0
10+
for rule in golden_rules:
11+
text, expected = rule
12+
segments = text_to_sentences(text).split('\n')
13+
if segments == expected:
14+
score += 1
15+
percent_score = (score / total_rules) * 100.0
16+
17+
if __name__ == "__main__":
18+
import timeit
19+
import pkg_resources
20+
version = pkg_resources.get_distribution("blingfire").version
21+
time_taken = timeit.timeit("blingfire_english_benchmark(GOLDEN_EN_RULES)",
22+
setup="from __main__ import blingfire_english_benchmark, GOLDEN_EN_RULES",
23+
number=100)
24+
print(f'{blingfire.__name__} - v{version}')
25+
print(f'GRS score: {percent_score:0.2f}%')
26+
print(f'Speed: {time_taken*1000:>10.2f} ms')
27+
# blingfire - v0.1.2
28+
# GRS score: 75.00%
29+
# Speed: 49.91 ms

requirements-benchmark.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ nltk==3.5
22
spacy==2.1.8
33
stanza==1.0.1
44
syntok==1.3.1
5+
blingfire==0.1.2

0 commit comments

Comments
 (0)