vn_tagger 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcfb6964248bf88b3e4051ba9ea6351882612785
4
- data.tar.gz: e15ffdef69db9b88ff8bdcf4e327a3b6966663ca
3
+ metadata.gz: a3e2987fc2377226b3a310d0ea144414b1fcb409
4
+ data.tar.gz: 67c6119fd7a08e03ce1fde5e06545f8756ecfac3
5
5
  SHA512:
6
- metadata.gz: 25912f78e1559bcf0f61142db640a7dcab007483a0cf258d4f0134938541c08f74125b8ac682598630e14c8d1fc042f2197b1aec704818b1bc07b032a1470e01
7
- data.tar.gz: 4b4296ce01cbaea6344a754887f8b8842e15ff233515eebe24d528a58b203b6861b1d288abc6b37a64c23c42580c2c01de5c1a9534776aebf531516a577cc073
6
+ metadata.gz: f8c8f43645f90f41cbcc34409e7e3d50afa24f550c072ffaf2c3dd67c2417d56ccab24b1029ece8f331c42e634d889f2950ed2955fafefaddee7a6dc02fc2e7b
7
+ data.tar.gz: afbb54e8772ec8d12c3449b11c47d26e3b83c30245168cb3a1716a6d6adf645f4a69e4bd594317416338ddee948ecafa2e2ed8751156282992d674e13015c169
@@ -18,12 +18,14 @@ module VnTagger
18
18
  end
19
19
 
20
20
  def xml_result
21
- @xml_result ||= if @success
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)
@@ -1,3 +1,3 @@
1
1
  module VnTagger
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -2,16 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  describe VnTagger::Tagger do
4
4
  describe '#tag' do
5
- 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.' }
6
- let(:tagger) { described_class.new(text) }
7
- let(:result) { tagger.result }
8
- let(:word) { result.words.first }
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
- it 'returns xml tagged text' do
11
- tagger.tag
12
- expect(result).to be_a(VnTagger::Document)
13
- expect(word.position).to eq 'Np'
14
- expect(word.text).to eq 'HLV'
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.1
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-07 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler