Skip to content

Commit e097b8a

Browse files
committed
load code
1 parent 877d4e4 commit e097b8a

File tree

23 files changed

+562
-0
lines changed

23 files changed

+562
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.history/
2+
/.vscode/
3+
/.DS_Store
4+
/data

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
# words_extractor
2+
23
Example of words extracting in Go, Crystal, Rust and Python
4+
5+
Text source: 79.4MB in 20 files
6+
7+
- Python 3.9.5 with sorting: 11s, without sorting 10s
8+
- Go 1.16.3 with sorting: 30s, without sorting: 20s
9+
- Rust 1.51.0 with sorting: 1m31s, without sorting: 1m10s
10+
- Crystal with sorting: 2m55s, without sorting: 27s
11+
12+
macOS 11.3.1, MacBook Pro (Retina, 15-inch, Late 2013)
13+
14+
```
15+
cd words_extractor_py
16+
python words.py
17+
18+
cd words_extractor_rs
19+
cargo run
20+
21+
cd words_extractor_go
22+
go run .
23+
24+
cd words_extractor_cr
25+
crystal run src/fast_words_cr.cr
26+
```

words_extractor_cr/.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.cr]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true

words_extractor_cr/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/docs/
2+
/lib/
3+
/bin/
4+
/.shards/
5+
*.dwarf
6+
/.history/
7+
/words/
8+
/fast_words_cr
9+
/.idea/
10+
/.DS_Store

words_extractor_cr/.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: crystal
2+
3+
# Uncomment the following if you'd like Travis to run specs and check code formatting
4+
# script:
5+
# - crystal spec
6+
# - crystal tool format --check

words_extractor_cr/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Jaroslaw Zabiello <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

words_extractor_cr/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# fast_words_cr
2+
3+
TODO: Write a description here
4+
5+
## Installation
6+
7+
TODO: Write installation instructions here
8+
9+
## Usage
10+
11+
TODO: Write usage instructions here
12+
13+
## Development
14+
15+
TODO: Write development instructions here
16+
17+
## Contributing
18+
19+
1. Fork it (<https://github.com/your-github-user/fast_words_cr/fork>)
20+
2. Create your feature branch (`git checkout -b my-new-feature`)
21+
3. Commit your changes (`git commit -am 'Add some feature'`)
22+
4. Push to the branch (`git push origin my-new-feature`)
23+
5. Create a new Pull Request
24+
25+
## Contributors
26+
27+
- [Jaroslaw Zabiello](https://github.com/your-github-user) - creator and maintainer

words_extractor_cr/shard.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version: 2.0
2+
shards: {}

words_extractor_cr/shard.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: fast_words_cr
2+
version: 0.1.0
3+
4+
authors:
5+
- Jaroslaw Zabiello <[email protected]>
6+
7+
targets:
8+
fast_words_cr:
9+
main: src/fast_words_cr.cr
10+
11+
crystal: 1.0.0
12+
13+
license: MIT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require "./spec_helper"
2+
3+
describe FastWordsCr do
4+
it "should be understand PL collations" do
5+
words = %w(ala ąla ćma ciemno ęle element łódź lody śmierć serial źdźbło żółw zawias)
6+
expected = %w(ala ąla ciemno ćma element ęle lody łódź serial śmierć zawias źdźbło żółw)
7+
words.sort { |x, y| FastWordsCr.cmp(x, y) }.should eq(expected)
8+
end
9+
10+
it "should be understand PL collations for q" do
11+
words = %w(ala ąla ćma ciemno ęle element łódź lody śmierć serial źdźbło żółw zawias querty)
12+
expected = %w(ala ąla ciemno ćma element ęle lody łódź querty serial śmierć zawias źdźbło żółw)
13+
words.sort { |x, y| FastWordsCr.cmp(x, y) }.should eq(expected)
14+
end
15+
16+
it "should understand PL collations for upper chars" do
17+
words = %w(ala ąla Ćma ciemno Ęle Element łódź lody śmierć serial źdźbło żółw zawias querty)
18+
expected = %w(ala ąla ciemno Ćma Element Ęle lody łódź querty serial śmierć zawias źdźbło żółw)
19+
words.sort { |x, y| FastWordsCr.cmp(x, y) }.should eq(expected)
20+
end
21+
end

0 commit comments

Comments
 (0)