vn_tagger 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vn_tagger/tagger.rb +7 -1
- data/lib/vn_tagger/version.rb +1 -1
- data/spec/vn_tagger/tagger_spec.rb +24 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3e2987fc2377226b3a310d0ea144414b1fcb409
|
4
|
+
data.tar.gz: 67c6119fd7a08e03ce1fde5e06545f8756ecfac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c8f43645f90f41cbcc34409e7e3d50afa24f550c072ffaf2c3dd67c2417d56ccab24b1029ece8f331c42e634d889f2950ed2955fafefaddee7a6dc02fc2e7b
|
7
|
+
data.tar.gz: afbb54e8772ec8d12c3449b11c47d26e3b83c30245168cb3a1716a6d6adf645f4a69e4bd594317416338ddee948ecafa2e2ed8751156282992d674e13015c169
|
data/lib/vn_tagger/tagger.rb
CHANGED
@@ -18,12 +18,14 @@ module VnTagger
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def xml_result
|
21
|
-
@xml_result ||= if
|
21
|
+
@xml_result ||= if is_success?
|
22
22
|
file = File.open(OUTPUT)
|
23
23
|
xml_document = Nokogiri::XML(file)
|
24
24
|
file.close
|
25
|
+
File.delete(OUTPUT)
|
25
26
|
xml_document
|
26
27
|
else
|
28
|
+
File.delete(OUTPUT)
|
27
29
|
Nokogiri::XML('')
|
28
30
|
end
|
29
31
|
end
|
@@ -40,6 +42,10 @@ module VnTagger
|
|
40
42
|
|
41
43
|
private
|
42
44
|
|
45
|
+
def is_success?
|
46
|
+
@success && File.exists?(OUTPUT)
|
47
|
+
end
|
48
|
+
|
43
49
|
def write_to_file
|
44
50
|
file = File.new(INPUT, 'w')
|
45
51
|
file.write(@text)
|
data/lib/vn_tagger/version.rb
CHANGED
@@ -2,16 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe VnTagger::Tagger do
|
4
4
|
describe '#tag' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
context 'when tags successfully' do
|
6
|
+
let(:text) { 'HLV cùa Chelsea không hối tiếc vì hành động bỏ về sớm trong trận gặp Aston Villa.' }
|
7
|
+
let(:tagger) { described_class.new(text) }
|
8
|
+
let(:result) { tagger.result }
|
9
|
+
let(:word) { result.words.first }
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
it 'returns xml tagged text' do
|
12
|
+
tagger.tag
|
13
|
+
expect(result).to be_a(VnTagger::Document)
|
14
|
+
expect(word.position).to eq 'Np'
|
15
|
+
expect(word.text).to eq 'HLV'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when there is error' do
|
20
|
+
let(:text) { 'mourinho@chelsea: HLV cùa Chelsea không hối tiếc vì hành động bỏ về sớm trong trận gặp Aston Villa.' }
|
21
|
+
let(:tagger) { described_class.new(text) }
|
22
|
+
let(:result) { tagger.result }
|
23
|
+
let(:word) { result.words.first }
|
24
|
+
|
25
|
+
it 'returns xml tagged text' do
|
26
|
+
tagger.tag
|
27
|
+
expect(result).to be_a(VnTagger::Document)
|
28
|
+
expect(word).to be_nil
|
29
|
+
end
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vn_tagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hieu Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|