cannawen / metric_units_reddit_bot Goto Github PK
View Code? Open in Web Editor NEWReddit bot converting imperial units to metric units
Home Page: https://www.reddit.com/user/metric_units
License: GNU General Public License v3.0
Reddit bot converting imperial units to metric units
Home Page: https://www.reddit.com/user/metric_units
License: GNU General Public License v3.0
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Enhancement request: "pound-force" units should be converted to Newtons.
See this commit for an example of how to add a new conversion
Recommended skills: Basic javascript & basic regular expressions
Estimated time: 30 minutes
Comment below if you would like to take on this task!
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Currently, acres are always converted to km^2 (1 acre = 0.00404686 km ^2)
Enhancement request: Acres should be converted to km^2, hectares, or m^2 (preferring to use the largest unit possible without using decimal places)
See conversion_helper.js to get started
Recommended skills: Basic javascript
Estimated time: 30 minutes
Comment below if you would like to take on this task!
I feel like this bot would be much more useful if it just gave rounded amounts dictated by the rules of significant figures. So instead of converting something like 2 miles to 3.2 km the bot could just write something like "≈3 km" or "approximately 3 km".
In the example there's only one significant figure (the 2) and the result should also have one. It's just a bit more pleasant.
Rounding by 5% is too lenient when dealing with two close numbers. Bot should be more precise when necessary.
Up to implementer to propose what values and thresholds to use, to define two (or more) "close" numbers and what kind of precision is "good enough"
Examples:
https://www.reddit.com/r/metric_units/comments/73edn2/constructive_feedback_thread/do4g33n
** Potential first timers only story - needs more description **
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Knots should be converted to metric speed (i.e. km/h)
See this commit for an example of how to add a new conversion
If there are no open issues on github but you would like to contribute to metric_units reddit bot, you can take a look at Pivotal Tracker and create your own github issues based on the ideas there. You can find stories under the "unassigned" marker, or in the Icebox if you are feeling adventurous!
Thank you for your interest :)
Given a post contains the unit "oz" but NOT "fl oz" unit
If the post text also contains the keywords:
liquid, water, tea, beer, soda, cider, juice, coffee, liquor, milk, bottle, spirits, rum, vodka, tequila, etc...
The "oz" should be converted to "fl oz"
This can be done in a pre-processing step in the fl oz conversion object
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion. What makes it sassy? The bot sometimes replies to comments like "good bot" and "bad bot" with its personality module.
This story is to give the bot even more personality! It should also reply to comments like "cute/adorable/kawaii bot" with even more cuteness and/or flirtation.
Possible replies:
Stop it, you're making me blush!
So... do... you want to grab a drink later? ^blush
...and anything else you feel is appropriate. Feel free to use lots of Japanese emoticons (◕‿◕✿)
See personality.js and personality-test.js to get started.
Leave a comment if you would like to take this on!
Acres should be converted to km^2
See this commit for an example of how to add a new conversion
When the bot sees "I would walk 500 miles" it should respond "And I would walk 804.672km more" (or other similar joke responses)
This is more complex than adding a standard personality, because this relies on new comments and not comment replies.
** Potential first timers only story - needs more description **
mpg means minutes per game, and the basketball fans are very unhappy.
Similar fix to #39 , ignore all nba team names from "mpg" conversion
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
I have no idea who would use pecks (other than peter piper, who picked a peck of pickled peppers...) but if someone ever does, it should be converted to something less silly!
See this commit for an example of how to add a new conversion (and note you can leverage the helper function volumeMap()
to convert to metric volume units)
Leave a comment if you would like to take this on!
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Current behaviour:
Enhancement request:
See this commit for an example of how to add a new conversion
Recommended skills:
Basic javascript & basic regular expressions
Estimated effort:
30 minutes
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
It's not quite metric, but it might be helpful to convert distances to light-seconds
See distanceMap
in conversion_helper.js to get started
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Current behaviour:
Problem:
While this works the majority of the time, for some values this may lead to too much rounding.
Enhancement request:
Find an algorithm that can handle these cases to round "appropriately."
Possible solution:
In step 1 of the current algorithm, perhaps we can always round to 1% error, instead of matching the number of decimals? Open to any other ideas you can come up with.
See conversion_helper.roundConversions to get started!
Recommended reading:
CONTRIBUTING.md (sections "Etiquette", "Work on an issue" and "Make a PR" are most important)
Recommended skills:
Basic javascript & basic regular expressions
Estimated effort:
30-60 minutes
Once #59 is merged, we should start fixing the things that eslinter points out.
Most of the errors can be autofixed by running the linter with the --fix
parameter. The remaining ones will have to be fixed by hand
Two places to change:
npm run-script lint
in .travis.yml file should be uncommented, so our CI will run the linterAnd then we need to go through every file and make sure it passes the linter :)
metric_units is a badly-tested reddit bot that finds imperial units, and replies with a metric conversion. Can you help make it less bad?
bot-test.js is an abomination where I rolled my own doubles (terrible idea, btw). Do you know how to unit test interactions between different files? Any libraries that can help? CAN YOU SAVE THIS POOR FILE (Or, just put it out of its misery and start from scratch)
Currently using mocha, chai, and proxyquire but open to new suggestions
Digital Ocean, ubuntu, supervisord, etc.
Discussion from here
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Current behaviour:
The README and CONTRIBUTING pages are very long. This makes it hard to find what you want
Enhancement request:
This chore is to research and add a solution for automatically-generated table of contents for markdown. Consider doctoc, but open to other suggestions!
Recommended reading:
CONTRIBUTING.md (sections "Etiquette", "Work on an issue" and "Make a PR" are most important ... see how hard it was to find those sections!?)
Recommended skills:
Basic Markdown
Estimated effort:
30-60 minutes
GitHub issues does not seem like a great platform for discussions. The conversation is linearly organized and chronologically ordered.
Should only the top post be made on GitHub, and then locked while linking to a discussion thread on /r/metric_units subreddit? Reddit seems like a much more natural place for discussions, where each point can be a separate comment and there can be comment replies. Sorting by upvotes would also be nice
Pros:
Cons:
Once a "decision" has been reached on reddit, the decision can be copied back to Github and the Reddit post can be locked.
Re-visiting a discussion on the topic must be done through a new issue/thread
Any feedback from the community?
Give a thumbs up if you like the Reddit idea, thumbs down if you don't.
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Furlongs should be converted to metric distances (meters, km, etc.)
See this commit for an example of how to add a new conversion
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Enhancement request: "bushels" should be converted to metric weights.
See this commit for an example of how to add a new conversion
Recommended skills: Basic javascript & basic regular expressions
Estimated time: 30 minutes
Comment below if you would like to take on this task!
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Enhancement request:
Investigate how to get test coverage data into the README.md file.
One possible solution is to use Coveralls. Any other suggestions are welcome.
Recommended reading:
CONTRIBUTING.md (sections "Etiquette", "Work on an issue" and "Make a PR" are most important)
Estimated effort:
30-60 minutes
Use Numeral.js to localize number recognition (i.e. 4,32 vs. 4.32)
Now that we have a preprocess step, we can remove commas from the input string but it might be a bit tricky because we don't want to blanket get rid of all commas (for example "40 miles,foo" would turn into "40 milesfoo" which would not be processed as miles )
Another problem:
Numbers formatted like 4,32 might be an alternate way to say 4.32 but 4,321 is more commonly the number "4321". Currently, we do not match numbers that are formatted like "4,32"
Perhaps there is a library out there for parsing numbers from different locales? If not perhaps we can spin off a new project to create such a library?
Issue is open for discussion
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Current behaviour: The bot converts bushels to ~32 lbs
Enhancement request:
The unit "bushel" should change depending on the commodity.
metric_units bot should search for keywords to figure out what kind of bushel it is translating, based on this link
For example:
If it does not find any keywords, it should not translate the bushel.
See this file to get started. Hint: it may help to have a "preprocess" step that searches for the unit "bushel" and replaces it with "bushel60" or "bushel32" depending on what kind of bushel it is.
Recommended skills: Javascript & regular expressions
Estimated time: 1-2 hours
In this regex, it matches "mr.? bot".
The "." matches any character.
In theory, it looks like it could reply to "mrs bot" with "Actually, I prefer the female gender pronoun. Thanks.", which would be kinda funny.
Open source is scary.
We should make it as easy as possible for newbies to contribute to open source
Some ideas, in no particular order:
If you have any comments or any more ideas, I would love to hear feedback (both positive and negative)!
I would especially love to hear from people who have never contributed to open source. What can we do to help you get started? What do you think of the ideas listed above?
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Enhancement request: Light seconds are used too liberally.
Change code so that >2 million miles are converted to light seconds. See this file to get started
Recommended skills: Basic javascript
Estimated time: 20 minutes
Comment below if you would like to take on this task!
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Enhancement request:
Troy ounces are often used in precious metal subreddits, and they are different from regular ounces.
See this commit for an example of how to add a new conversion. You can consider using a "preprocess" step to convert all text mentions of "ounces" to "troy ounces" when appropriate
Recommended skills: Basic javascript & basic regular expressions
Estimated time: 60 minutes
Comment below if you would like to take on this task!
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
This issue is reserved for anyone who has never made a pull request to Open Source Software. If you are not a first timer, we would still love your help! Please see our other open issues :)
Read our New to OSS guide for an overview of what to expect
if
statements, arrays, etc.)30-60 minutes
So, you want to work on a Reddit bot that converts imperial units to metric units? Awesome! It's not an easy problem to solve though :( Imperial units are confusing!!
Take ounces, for example. When someone says "ounces" they usually mean regular ("avoirdupois") ounces (which is 28.3495 grams). But, they could also be referring to "troy" ounces (31.1035 grams). Troy ounces are most often used when dealing with precious metals, like gold or silver
The subreddit /r/Pmsforsale is all about precious metals. They may refer to something as "ounce", but what they really mean is "troy ounce"
So, when the bot finds itself in /r/Pmsforsale, we want it to find all mentions of "ounces" and replace them with "troy ounces". This should already be happening, but it is not! There is a bug in the code.
To replace "ounces" with "troy ounces", we must find them by using a thing called Regular Expressions (also known as a, "regex"). Regexes help us find strings that match a certain pattern. For example if we had a regex a
and applied it to this string: ababcA
... it would find all of the lower case a's but ignore the other characters (b, c, and A).
OPTIONAL: You can go through this tutorial to learn more about regexes
OK, we are ready to get started. Lets get our development environment set up!
If you run into any problems, try googling for a solution. If that doesn't work, reply to this issue with screenshots of the error and what steps you have already taken to try to solve the problem. We're happy to help :)
node --version
npm install
to download all of the required dependenciesnpm test
to run all of the tests. All green? Yay!./src/conversion_helper-test.js
in your favourite text editorit.skip
with it.only
. This will tell the program to only run this single test. While you're here, take a look at the test! Read it carefully, can you guess what it does?npm test
again./src/conversion_helper.js
and find where we declare specialSubredditsRegex
it.only
to it
to run all of the tests again.metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Current behaviour:
mph is translated to metric speed, but feet per second is not
Enhancement request:
Feet per second values should be translated to metric speed
See this commit for an example of how to add a new conversion
Recommended skills:
Basic javascript & basic regular expressions
Estimated effort:
30 minutes
Currently, the bot handles ranges in a non-intuitive way by displaying each value separately, the current ranges handling can be made much better instead if we process them separately in findPotentialConversions
and formatConversion
to do the following:
1-2 miles ≈ 1.6-3.2 km
1 to 2 miles ≈ 1.6 to 3.2 km
, 1 or 2 miles ≈ 1.6 or 3.2 km
and similar.I think I can work on this(if the changes make sense?)
The bot is currently rounding to the same number of decimals as input or 3-5% error, but it should be following standard rounding rules.
when adding or subtracting the answer should have the same amount of decimals as the least precise number. When multiplying or dividing the product should have the same number of significant figures as the least precise factor
EDIT: CONTRIBUTE.md document created, but feel free to keep discussing process-related improvements that can be made
Hey everyone!
I am having some problems with our current process, where Alice volunteers to fix an issue, but then Bob makes a PR for it (either not noticing the "already-assigned" tag, or they started working on it without commenting on the issue). There are also times I don't know a story is being worked on, and suddenly a PR appears. It's awesome that unexpected features are "magically" getting done, but also a bit scary
While it's amazing to have so much interest, I feel like this lack of transparency is not sustainable because there may be duplicated efforts (and that would 100% suck).
I am thinking of making a CONTRIBUTING.md document that states if you start working on something, you must make a github issue to let everyone else know. Some concerns/questions I have:
I am opening this issue for discussion, has anyone else run into this kind of problem before? Can anyone think of a good solution? Any thoughts or feedback are welcome.
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
When it finds itself in /r/totallynotrobots, metric bot disguises itself as human because well... of course it's not a robot.
That being said, all humans have ages, whereas robots have version numbers. So this story is to change "v0.10.1" in metric bot's footer to say "age0.10.1"
See reply_maker.js to get started!
Similar to #28, our conversions file is getting out of hand. Consider refactoring so that each conversion's data is in a .yaml file
Consider using the regex length to sort the order of conversions, so "miles per hour" (14 char) will get triggered before "miles" (5 char).
Maybe we should stop adding new conversions, until this refactor is in place?
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion. What makes it sassy? The bot sometimes replies to comments like "good bot" and "bad bot" with its personality module.
This story is to give the bot even more personality! It should also reply to comments like "ok bot" or "mediocre bot".
Possible replies:
/shrug, I'll take it
That's just like, your opinion, man
...and anything else you feel is appropriate
See personality.js and personality-test.js to get started
Repro steps:
Expected: metric_unit bot should also edit its comment to say "5 feet ~ 1.5 metres"
Actual: metric_bot's reply still says "50 feet ~ 15 metres"
Discussion:
This is a pretty complicated story to do, because there is no notification when a user edits their comment. The current behaviour is not an ideal user experience, but is this something we want to fix?
i.e. 50k miles should be processed to 50000 miles
A quick solution for this would be to add k matching to the number_regex so when we are parsing 50k
we match 50k
instead of 50
like we do currently. We could then either replace the k
with 000
or cast the string as a number and multiply it by 1000
.
@cannawen What's your opinion on this? Should we also parse numbers like 20.2k
to 20200
?
I would like to work on this.
Modify the existing pressureMap so 10^5 pa or more are converted to bars.
Relevant function
lbs/inch should be converted to kg/mm and N/m, these are units for spring rate forces, surface tension etc.
Basic javascript & basic regular expressions
Estimated time: 30 minutes
Comment below if you would like to take on this task!
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Nautical miles should be converted to metric distances (meters, km, etc.)
See this commit for an example of how to add a new conversion
metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.
Enhancement request:
deasync
is used to create functions that act like they are synchronous, but, this is very non-idiomatic (i.e. "things aren't typically done this way in javascript-land"), unnecessary (i.e. it is possible to implement in other ways), and affects performance.
Potential patterns to refactor with: callbacks, promises or await.
deasync
should be removed from:
src/bot.js
src/network.js
networkRequest()
refreshToken()
package.json
Note: changes will also need to be made to functions that make use of networkRequest()
and refreshToken()
and so on...
Recommended reading:
CONTRIBUTING.md (sections "Etiquette", "Work on an issue" and "Make a PR" are most important)
Recommended skills:
Javascript
Estimated effort:
1-2 hours
Currently '
and "
are used interchangeably in the code, for the sake of standardization and code legibility we should pick one as the standard and fix the remaining quotes on the code.
@cannawen Do you have any preference between '
and "
?
Maybe a coding guideline of sorts could be defined so everyone is on the same page. (tabs vs spaces, space between brackets, etc)
See this comment, imgur album id was 62lbS
and the bot interpreted that as a measurement. This is very rare most likely, and markdown parsing could be tricky, but is a bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.