Giter Site home page Giter Site logo

metric_units_reddit_bot's People

Contributors

annuhdo avatar aterranova-bv avatar bclingan avatar cannawen avatar chazzlabs avatar cmd-kvn avatar doomki avatar eliotw avatar esclear avatar fbontin avatar jacobscottallen avatar juanpotato avatar mayankagarwal2402 avatar mfogleman avatar michaelbutler avatar miporto avatar nalinbhardwaj avatar namantw avatar nicolasferraro avatar nitinkgp23 avatar rafd avatar seandgrimes avatar shrink avatar sirugh avatar skuhoo avatar winglian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metric_units_reddit_bot's Issues

Convert nautical miles to km

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

Feet per second values should be converted to metric speed

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

Comment below if you would like to take on this task!

Ignore all nba subreddits for mpg

** 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

Improve rounding

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

Add library for unit testing in javascript

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

Handling ranges better

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:

  • Display ranges in comment as ranges in response, for example, 1-2 miles ≈ 1.6-3.2 km
  • Handle many more joining keywords, such as 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?)

Discussion - Discussions

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:

  • better discussion format
  • Redditors without GitHub accounts can contribute

Cons:

  • you need to create a Reddit account to contribute
  • information scattered across platforms (you need to check Reddit and GitHub to keep current)

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.

"troy ounces" should be converted to metric weights

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.

  1. When the bot sees "troy ounces" it should be converted to metric weights.
  2. When the bot sees "ounces" in a precious metal subreddit (/r/silverbugs or /r/pmsforsale) then it should convert as troy 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!

Handle commas better

Enhancement request summary:

Use Numeral.js to localize number recognition (i.e. 4,32 vs. 4.32)

Initial discussion:

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

Create personality response for "cute bot"

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!

"bushels" should be converted to metric weights

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!

Bot should update conversions on edited posts

Repro steps:

  1. Alice makes a reddit comment that says "50 feet"
  2. metric_units bot sees it, and responds with "50 feet ~ 15 metres"
  3. Alice edits her comment to say "5 feet"

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?

standardize ' vs " [#151046132]

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)

Bushel conversion should depend on keyword.

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 finds the word "oats" in the comment, it should convert it to a 32-lb bushel.
  • if it finds "soybeans" it should convert to a 60-lb bushel.

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

Comment below if you would like to take on this task!

Keyword triggers for fl oz instead of oz conversions

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

Standardize code

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:

  1. npm run-script lint in .travis.yml file should be uncommented, so our CI will run the linter
  2. this commit should be reverted, so the linter runs before every commit

And then we need to go through every file and make sure it passes the linter :)

Personality response for "I would walk 500 miles"

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.

Allow for k to represent thousand [#151447001]

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.

Feedback request - Process discussion

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:

  1. Should PRs without open github issues be rejected? Perhaps if there is no conflict, the PR can be accepted with a warning for next time?
  2. If someone opens a PR for an issue they were not assigned, should the PR be rejected? What if the original assignee does not finish the issue?
  3. How long should an issue be assigned to a person for? Should we enforce a "deadline" for when a feature must be done?

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.

"pound-force" should be converted to Newtons

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!

Significant Figures?

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.

Feature request: Convert lbs/inch to kg/mm and N/m

Issue description

lbs/inch should be converted to kg/mm and N/m, these are units for spring rate forces, surface tension etc.

Recommended skills

Basic javascript & basic regular expressions

Relevant Links

Reddit comment

Estimated time: 30 minutes

Comment below if you would like to take on this task!

Square inches should be converted to metric areas

metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.

Current behaviour:

  1. Acres are translated to metric areas, but square inches are not.
  2. Metric areas include m^2, hectares, and km^2

Enhancement request:

  1. inches^2 should be converted to metric areas
  2. cm^2 should be one of the metric area options

See this commit for an example of how to add a new conversion

Recommended skills:
Basic javascript & basic regular expressions

Estimated effort:
30 minutes

Comment below if you would like to take on this task!

"oz" is not being converted to "troy oz" in subreddit /r/Pmsforsale

metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.

First timers only

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

IMPORTANT: Comment below if you would like to volunteer to fix this bug.


Recommended experience

  • Programming fundamentals (if statements, arrays, etc.)
  • No previous experience working with Regular Expressions
  • Some familiarity with how Reddit works

Time estimate

30-60 minutes

Background Information

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 problem

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 :)

  1. Open up a terminal window and type node --version
  2. If it complains you do not have node, download it here.
  3. If your Node version is under v6.2.1, you have to update it
  4. Fork the main github repository and "clone your fork" (download the bot's code) using git. See more detailed instructions here
  5. Run npm install to download all of the required dependencies
  6. Run npm test to run all of the tests. All green? Yay!
  7. Open ./src/conversion_helper-test.js in your favourite text editor
  8. Search for the text "should convert oz to troy oz in precious metal sub"
  9. Replace it.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?
  10. Run npm test again
  11. Observe failing test :( Boo, failing tests! Booo! Tests allow us to define inputs and expected outputs to functions, so we can see if a function is doing the correct thing.
  12. This test is failing because of a bug in the code. Let's go find that code
  13. Go to ./src/conversion_helper.js and find where we declare specialSubredditsRegex
  14. This line creates a regex, but all regexes are case-sensitive by default! Notice the difference in capitalization in our test vs. our regular expression?
  15. Your task is to make the regex match case-insensitively to make the test pass. Please use Google or any other resource.
    OPTIONAL: Can you think of other ways to make the test pass? Post your ideas in your Pull Request description later on (step 18).
  16. Once your single test is passing, change the it.only to it to run all of the tests again.
  17. Is everything green? Woohoo, green! Yay!!
  18. Please commit the changes with a descriptive git commit message, and then make a pull request back to the main repository :)
    OPTIONAL: Don't forget to give yourself credit! Thank you for contributing to metric_units bot!
  19. Wait for your PR to be reviewed by a maintainer, and address any comments they may have

Step 20: YOUR CHANGE GETS MERGED AND RELEASED!! Party!!!

"mr.? bot"

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.

see: https://regex101.com/r/Isy8YX/2

Refactor network module to avoid use of deasync

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
    • require (unused in this module anyway)
  • src/network.js
    • require
    • 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

Convert "pecks" to litres

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!

*** CREATE YOUR OWN ISSUE ***

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 :)

Add test coverage statistics to repository

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

Comment below if you would like to take on this task!

Discussion - Improve new contributor experience

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:

  • 1) issues tagged "first timers only" (only open to those who have never contributed to OSS) that require < 30min to complete, and have more detailed instructions
    [CHECK, first issue created #79 . We will see how it goes, and iterate from there]
  • 2) create branches with failing tests, that first timers need to make pass
    [CHECK, failing test is pushed into master with .skip keyword]
  • 3) adding a document targeted at first timers, listing how-to resources and encouraging them to participate
    [CHECK, New to OSS Guide]
  • 4) fostering a welcoming community that encourages and helps newbies get started in open source
    [CHECK, I don't know about "fostering", but updated documentation to include code of conduct]
  • 5) update "vision" statement to add "encourage more people to participate in open source"
    [CHECK, done]
  • 6) there are different kinds of "first timers" - those new to open source, those new to programming, and those new to the tech stack. We should target different stories to different kinds of newbies
    [CHECK, just something to keep in mind]
  • 7) add our project to http://up-for-grabs.net/#/
  • 8) example of awesome first-time experience
    [CHECK, just something to keep in mind]

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?

Generate table of contents for README.md and CONTRIBUTING.md

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

Conversions architecture overhaul

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?

This issue is open for discussion on reddit

Create personality response for "ok/mediocre/meh bot"

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

Improve rounding for small numbers

metric_units is a sassy reddit bot that finds imperial units, and replies with a metric conversion.

Current behaviour:

  1. If an input number has a decimal place, the output number will have an equal amount of decimal places (i.e. 1.1111 miles -> 1.7881 km)
  2. Else if the input number is greater than 100 and it ends in a "0" then the output number will be rounded to within 5% accuracy
  3. Else the number will be rounded to within 3% accuracy

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

Comment below if you would like to take on this task!

Acres should be converted to km^2, hectares, or m^2

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.