-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle units containing 'degree' and 'per' correctly #56
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7dd3db5
Handle units containing 'degree' and 'per' correctly
nielstron f29df70
Include more difficult tests
nielstron f87c0b9
Fix plural of 'pound-force'
nielstron c0d198f
Capitalize Celsius
nielstron dd01c0b
Refine degree handling
nielstron File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,56 @@ | |
|
||
import inflect | ||
|
||
p = inflect.engine() | ||
|
||
class TestCompounds(object): | ||
def setup(self): | ||
self.p = inflect.engine() | ||
|
||
def test_compound_1(self): | ||
eq_(self.p.singular_noun('hello-out-there'), 'hello-out-there') | ||
def test_compound_1(): | ||
eq_(p.singular_noun('hello-out-there'), 'hello-out-there') | ||
|
||
def test_compound_2(self): | ||
eq_(self.p.singular_noun('hello out there'), 'hello out there') | ||
|
||
def test_compound_3(self): | ||
eq_(self.p.singular_noun('continue-to-operate'), 'continue-to-operate') | ||
def test_compound_2(): | ||
eq_(p.singular_noun('hello out there'), 'hello out there') | ||
|
||
def test_compound_4(self): | ||
eq_(self.p.singular_noun('case of diapers'), 'case of diapers') | ||
|
||
def test_compound_3(): | ||
eq_(p.singular_noun('continue-to-operate'), 'continue-to-operate') | ||
|
||
|
||
def test_compound_4(): | ||
eq_(p.singular_noun('case of diapers'), 'case of diapers') | ||
|
||
|
||
def test_unit_handling_degree(): | ||
test_cases = { | ||
'degree celsius': 'degrees celsius', | ||
'degree fahrenheit': 'degrees fahrenheit', | ||
'degree rankine': 'degrees rankine' | ||
} | ||
for singular, plural in test_cases.items(): | ||
eq_(p.plural(singular), plural) | ||
|
||
|
||
def test_unit_handling_fractional(): | ||
test_cases = { | ||
'pound per square inch': 'pounds per square inch', | ||
'pound-force per square inch': 'pound-forces per square inch', | ||
'metre per second': 'metres per second', | ||
'kilometre per hour': 'kilometres per hour', | ||
'cubic metre per second': 'cubic metres per second', | ||
'dollar a year': 'dollars a year', | ||
# Correct pluralization of denominator | ||
'foot per square second': 'feet per square second', | ||
'mother-in-law per lifetime': 'mothers-in-law per lifetime' | ||
} | ||
for singular, plural in test_cases.items(): | ||
eq_(p.plural(singular), plural) | ||
|
||
|
||
def test_unit_handling_combined(): | ||
test_cases = { | ||
# Heat transfer coefficient unit | ||
'watt per square meter degree celsius': 'watts per square meter degree celsius', | ||
'degree celsius per hour': 'degrees celsius per hour' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Big C in "Celsius" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs #55 then to be merged into master to work. |
||
} | ||
for singular, plural in test_cases.items(): | ||
eq_(p.plural(singular), plural) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad example, I think the real plural is something like "pounds-force per square inch"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I think this is correct:
"pound-force (plural pound-forces)" from Wiktionary
I do agree though that at first sight this does not sound correct...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the Oxford English Dictionary:
None of the other 10 dictionaries I checked show a plural form at all.
Google Books has 66 results for "pounds force per inch".
But only two results for "pound forces per inch".
The plural form on Wiktionary was added when the
en-noun
template was simply added, without taking care of the special-case plural:https://en.wiktionary.org/w/index.php?title=pound-force&diff=13830692&oldid=13487437
I've fixed Wiktionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metric is so much easier :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, fixed pluralization of 'pound-force' (and 'pound-weight' I hope) too