linter 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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/data/pronoun_association_wordlist.yml +11 -0
- data/lib/linter.rb +1 -0
- data/lib/linter/base_association.rb +24 -1
- data/lib/linter/gender_association.rb +1 -18
- data/lib/linter/pronoun_association.rb +18 -0
- data/lib/linter/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 132bd553ebe8639ffa00c6c6662655a9d3356c54676630dd70696b844ab31f94
|
4
|
+
data.tar.gz: 6bbeac0a7ac6394dedeba49290344f466063c46a30651bd8d918d75e7ea7937c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bbd652dde4ac9056e2082e21b376952787c6881885d5059a36ee3a8e0a5bbf2f0becc0b451dc92bbd2fe5d4439b0c2e0f83d2da1289d56f07542cbd964c289f
|
7
|
+
data.tar.gz: 31c8988bfc69608a44795104df41384699448b4d9a1c2ebb932d9cae854240dc27741eec549386672834df60c60f766ee41231e3908b1bc8e3ae2c8b0af81678
|
data/Gemfile.lock
CHANGED
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
|
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://
|
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).
|
data/lib/linter.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/linter/version.rb
CHANGED
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.
|
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-
|
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
|