agenda 0.1.2 → 0.1.3
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.
- data/config/dics/commons.yaml +1 -0
- data/config/dics/conjugations.yaml +1 -0
- data/features/dictionaries.feature +36 -0
- data/features/steps/dictionaries.rb +21 -0
- data/features/support/hooks.rb +3 -0
- data/lib/agenda.rb +23 -3
- data/lib/agenda/version.rb +1 -1
- metadata +6 -3
@@ -0,0 +1 @@
|
|
1
|
+
preposition: [of, with, a]
|
@@ -0,0 +1 @@
|
|
1
|
+
go: [went, going]
|
@@ -12,6 +12,7 @@ Feature: Dictionaries
|
|
12
12
|
When is loaded
|
13
13
|
Then I should get a discarded chars regexp
|
14
14
|
|
15
|
+
@dictionary
|
15
16
|
Scenario: Negatively loaded words
|
16
17
|
Given the file "config/dictionary.yaml"
|
17
18
|
And it contains:
|
@@ -22,6 +23,7 @@ Feature: Dictionaries
|
|
22
23
|
Then I should get a negative words dictionary
|
23
24
|
And negative dictionary should have "disgrace"
|
24
25
|
|
26
|
+
@dictionary
|
25
27
|
Scenario: Common words
|
26
28
|
Given the file "config/dictionary.yaml"
|
27
29
|
And it contains:
|
@@ -31,6 +33,7 @@ Feature: Dictionaries
|
|
31
33
|
When is loaded
|
32
34
|
Then I should get a common words dictionary
|
33
35
|
|
36
|
+
@dictionary
|
34
37
|
Scenario: Load dictionary
|
35
38
|
Given the file "config/alternate-dictionary.yaml"
|
36
39
|
And it contains:
|
@@ -41,6 +44,7 @@ Feature: Dictionaries
|
|
41
44
|
Then I should get a freak words dictionary
|
42
45
|
And I should get a common words dictionary
|
43
46
|
|
47
|
+
@dictionary
|
44
48
|
Scenario: Replace dictionary
|
45
49
|
Given the file "config/alternate-dictionary.yaml"
|
46
50
|
And it contains:
|
@@ -49,4 +53,36 @@ Feature: Dictionaries
|
|
49
53
|
"""
|
50
54
|
When I replace dictionaries with it
|
51
55
|
Then I should get a freak words dictionary
|
56
|
+
And I should not get a common words dictionary
|
57
|
+
|
58
|
+
@dictionary
|
59
|
+
Scenario: Load dictionaries from directory
|
60
|
+
Given the directory: "config/dics"
|
61
|
+
And it contains the file "commons.yaml" with:
|
62
|
+
"""
|
63
|
+
preposition: [of, with
|
64
|
+
"""
|
65
|
+
And it contains the file "conjugations.yaml" with:
|
66
|
+
"""
|
67
|
+
go: [went, going
|
68
|
+
"""
|
69
|
+
When I load the directory
|
70
|
+
Then I should get a preposition words dictionary
|
71
|
+
And I should get a go words dictionary
|
72
|
+
And I should get a common words dictionary
|
73
|
+
|
74
|
+
@dictionary
|
75
|
+
Scenario: Replace dictionaries from directory
|
76
|
+
Given the directory: "config/dics"
|
77
|
+
And it contains the file "commons.yaml" with:
|
78
|
+
"""
|
79
|
+
preposition: [of, with
|
80
|
+
"""
|
81
|
+
And it contains the file "conjugations.yaml" with:
|
82
|
+
"""
|
83
|
+
go: [went, going
|
84
|
+
"""
|
85
|
+
When I replace dictionaries with those in the directory
|
86
|
+
Then I should get a preposition words dictionary
|
87
|
+
And I should get a go words dictionary
|
52
88
|
And I should not get a common words dictionary
|
@@ -8,6 +8,19 @@ Given /it contains:/ do |content|
|
|
8
8
|
@the_content.should include(content)
|
9
9
|
end
|
10
10
|
|
11
|
+
Given /the directory: "(.+?)"$/ do |dir|
|
12
|
+
@dir_path = File.dirname(File.dirname(File.dirname(__FILE__))) + "/" + dir
|
13
|
+
Dir.should exist(@dir_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /it contains the file "(.+?)" with:$/ do |file, content|
|
17
|
+
@file_path = "#{@dir_path}/#{file}"
|
18
|
+
File.should exist(@file_path)
|
19
|
+
|
20
|
+
@content = File.read @file_path
|
21
|
+
@content.should include(content)
|
22
|
+
end
|
23
|
+
|
11
24
|
When /is loaded/ do; end
|
12
25
|
|
13
26
|
When /I load it/ do
|
@@ -18,6 +31,14 @@ When /I replace dictionaries with it/ do
|
|
18
31
|
Agenda.replace_dictionaries_with @path
|
19
32
|
end
|
20
33
|
|
34
|
+
When /I load the directory/ do
|
35
|
+
Agenda.load_dictionaries_from @dir_path
|
36
|
+
end
|
37
|
+
|
38
|
+
When /I replace dictionaries with those in the directory/ do
|
39
|
+
Agenda.replace_dictionaries @dir_path
|
40
|
+
end
|
41
|
+
|
21
42
|
Then /I should get a (.+?) words dictionary/ do |type|
|
22
43
|
Agenda.dictionary[type.to_sym].should_not be_empty
|
23
44
|
end
|
data/lib/agenda.rb
CHANGED
@@ -2,15 +2,15 @@ require "yaml"
|
|
2
2
|
|
3
3
|
module Agenda
|
4
4
|
|
5
|
-
base_path = File.dirname(File.dirname(File.expand_path(__FILE__)))
|
5
|
+
@@base_path = File.dirname(File.dirname(File.expand_path(__FILE__)))
|
6
6
|
|
7
|
-
@@base_dictionary = YAML.load_file "#{base_path}/config/dictionary.yaml"
|
7
|
+
@@base_dictionary = YAML.load_file "#{@@base_path}/config/dictionary.yaml"
|
8
8
|
@@dictionary = {}
|
9
9
|
@@base_dictionary.each do |key, value|
|
10
10
|
@@dictionary[key.to_sym] = value
|
11
11
|
end
|
12
12
|
|
13
|
-
@@regexp = YAML.load_file "#{base_path}/config/regexp.yaml"
|
13
|
+
@@regexp = YAML.load_file "#{@@base_path}/config/regexp.yaml"
|
14
14
|
|
15
15
|
@@regexp.each do |key, value|
|
16
16
|
@@regexp[key] = Regexp.new "[#{value}]"
|
@@ -19,6 +19,15 @@ module Agenda
|
|
19
19
|
def self.dictionary; @@dictionary; end
|
20
20
|
def self.regexp; @@regexp; end
|
21
21
|
|
22
|
+
def self.reset_dictionaries
|
23
|
+
@@dictionary = {}
|
24
|
+
@@base_dictionary = YAML.load_file "#{@@base_path}/config/dictionary.yaml"
|
25
|
+
@@dictionary = {}
|
26
|
+
@@base_dictionary.each do |key, value|
|
27
|
+
@@dictionary[key.to_sym] = value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
22
31
|
def self.load_dictionary(path)
|
23
32
|
YAML.load_file(path).each do |key, value|
|
24
33
|
@@dictionary[key.to_sym] = value
|
@@ -28,6 +37,17 @@ module Agenda
|
|
28
37
|
@@dictionary = {}
|
29
38
|
Agenda.load_dictionary(path)
|
30
39
|
end
|
40
|
+
|
41
|
+
def self.load_dictionaries_from(path)
|
42
|
+
Dir.new(path).each do |file|
|
43
|
+
Agenda.load_dictionary "#{path}/#{file}" if file.end_with? "yaml"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.replace_dictionaries(path)
|
48
|
+
@@dictionary = {}
|
49
|
+
Agenda.load_dictionaries_from path
|
50
|
+
end
|
31
51
|
end
|
32
52
|
|
33
53
|
# Gem own requires
|
data/lib/agenda/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agenda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &21271896 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *21271896
|
26
26
|
description: Text analysis package oriented to deconstruct discourse
|
27
27
|
email:
|
28
28
|
- xavier.via.canel@gmail.com
|
@@ -36,6 +36,8 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- agenda.gemspec
|
38
38
|
- config/alternate-dictionary.yaml
|
39
|
+
- config/dics/commons.yaml
|
40
|
+
- config/dics/conjugations.yaml
|
39
41
|
- config/dictionary.yaml
|
40
42
|
- config/regexp.yaml
|
41
43
|
- features/dictionaries.feature
|
@@ -44,6 +46,7 @@ files:
|
|
44
46
|
- features/steps/tagging.rb
|
45
47
|
- features/steps/word_count.rb
|
46
48
|
- features/support/env.rb
|
49
|
+
- features/support/hooks.rb
|
47
50
|
- features/tagged_result.feature
|
48
51
|
- features/tagging.feature
|
49
52
|
- features/word_count.feature
|