linter 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4db9f6d5a1807dcd24cf533361c76f9d12c20373f4dbe737107b0f503bc1291
4
- data.tar.gz: 1db34072b02382ca137a9d93fc72bc1521b97f63b6bf5df40150d6720d5c2706
3
+ metadata.gz: 132bd553ebe8639ffa00c6c6662655a9d3356c54676630dd70696b844ab31f94
4
+ data.tar.gz: 6bbeac0a7ac6394dedeba49290344f466063c46a30651bd8d918d75e7ea7937c
5
5
  SHA512:
6
- metadata.gz: 642727c1fe106a67f6770f708c4b7fe08715fc5bab059f697b5b895d9fb4dd540f5692cbe75993f677785a88bb8e70f79a07430a62f8bde3374809b9127a8e94
7
- data.tar.gz: b53ceb869f51bdff32a4430bf1d08a83fb7a8dfc6393fdefac03bb495caaf0850aff3925194df1e07a78a29b547efa7b7a711aaac9099df4de7376ece0896cc0
6
+ metadata.gz: 3bbd652dde4ac9056e2082e21b376952787c6881885d5059a36ee3a8e0a5bbf2f0becc0b451dc92bbd2fe5d4439b0c2e0f83d2da1289d56f07542cbd964c289f
7
+ data.tar.gz: 31c8988bfc69608a44795104df41384699448b4d9a1c2ebb932d9cae854240dc27741eec549386672834df60c60f766ee41231e3908b1bc8e3ae2c8b0af81678
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linter (0.1.0)
4
+ linter (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -40,4 +40,4 @@ DEPENDENCIES
40
40
  rspec (~> 3.0)
41
41
 
42
42
  BUNDLED WITH
43
- 1.17.1
43
+ 1.17.2
data/README.md CHANGED
@@ -37,7 +37,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
37
37
 
38
38
  ## Contributing
39
39
 
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/linter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
40
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/lienvdsteen/linter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
41
41
 
42
42
  ## License
43
43
 
@@ -45,4 +45,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
45
45
 
46
46
  ## Code of Conduct
47
47
 
48
- Everyone interacting in the Linter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/linter/blob/master/CODE_OF_CONDUCT.md).
48
+ Everyone interacting in the Linter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/lienvdsteen/linter/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,11 @@
1
+ feminine_coded:
2
+ - she
3
+ - her
4
+ - hers
5
+ - herself
6
+
7
+ masculine_coded:
8
+ - he
9
+ - his
10
+ - him
11
+ - himself
@@ -1,6 +1,7 @@
1
1
  require "linter/version"
2
2
  require "linter/base_association"
3
3
  require "linter/gender_association"
4
+ require "linter/pronoun_association"
4
5
 
5
6
  require 'yaml'
6
7
 
@@ -1,9 +1,32 @@
1
1
  module Linter
2
2
  class BaseAssociation
3
+ def self.analyze(text)
4
+ result = OpenStruct.new(
5
+ feminine_coded_word_counts: {},
6
+ masculine_coded_word_counts: {},
7
+ trend: ''
8
+ )
9
+
10
+ wordlists['feminine_coded'].each do |word|
11
+ result.feminine_coded_word_counts.merge!(word_count(text, word))
12
+ end
13
+
14
+ wordlists['masculine_coded'].each do |word|
15
+ result.masculine_coded_word_counts.merge!(word_count(text, word))
16
+ end
17
+
18
+ result.trend = calculate_trend(result)
19
+ result
20
+ end
21
+
3
22
  private
4
23
 
5
24
  def self.word_count(text, word)
6
- regex = /\b(#{word}\w*)\b/i
25
+ if self::FULL_WORD
26
+ regex = /\b#{word}\b/i
27
+ else
28
+ regex = /\b(#{word}\w*)\b/i
29
+ end
7
30
  matches = text.scan(regex)
8
31
  return {} unless matches.any?
9
32
 
@@ -1,23 +1,6 @@
1
1
  module Linter
2
2
  class GenderAssociation < BaseAssociation
3
- def self.analyze(text)
4
- result = OpenStruct.new(
5
- feminine_coded_word_counts: {},
6
- masculine_coded_word_counts: {},
7
- trend: ''
8
- )
9
-
10
- wordlists['feminine_coded'].each do |word|
11
- result.feminine_coded_word_counts.merge!(word_count(text, word))
12
- end
13
-
14
- wordlists['masculine_coded'].each do |word|
15
- result.masculine_coded_word_counts.merge!(word_count(text, word))
16
- end
17
-
18
- result.trend = calculate_trend(result)
19
- result
20
- end
3
+ FULL_WORD = false
21
4
 
22
5
  private
23
6
 
@@ -0,0 +1,18 @@
1
+ module Linter
2
+ class PronounAssociation < BaseAssociation
3
+ FULL_WORD = true
4
+
5
+ private
6
+
7
+ def self.wordlists
8
+ file_path = File.join(__dir__,'../../data/pronoun_association_wordlist.yml')
9
+ @wordlists ||= YAML.load_file(file_path)
10
+ end
11
+
12
+ def self.calculate_trend(result)
13
+ return 'masculine-coded' if result.masculine_coded_word_counts.values.sum.positive?
14
+ return 'feminine-coded' if result.feminine_coded_word_counts.values.sum.positive?
15
+ return 'neutral'
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Linter
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - lien van den steen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2020-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,9 +87,11 @@ files:
87
87
  - bin/console
88
88
  - bin/setup
89
89
  - data/gender_association_wordlist.yml
90
+ - data/pronoun_association_wordlist.yml
90
91
  - lib/linter.rb
91
92
  - lib/linter/base_association.rb
92
93
  - lib/linter/gender_association.rb
94
+ - lib/linter/pronoun_association.rb
93
95
  - lib/linter/version.rb
94
96
  - linter.gemspec
95
97
  homepage: https://gitlab.com/lienvdsteen/linter