Giter VIP home page Giter VIP logo

kgbtr / koyunotlatan Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 135 KB

Ak koyun ak bacağından, kara koyun kara bacağından asılır. Fakat koyunotlatanın mahareti, renkten öte, otlatma sanatındadır.

Home Page: https://reddit.com/user/koyunotlatan

License: GNU General Public License v3.0

Python 89.30% Dockerfile 7.48% Procfile 0.17% Shell 3.05%
bot reddit reddit-bot reddit-chatbot koyunkirpan koyunotlatan

koyunotlatan's Introduction

koyunotlatan

Shepherd Satyr grazing sheeps

Ak koyun ak bacağından, kara koyun kara bacağından asılır.
Fakat koyunotlatan'ın mahareti, renkten öte, otlatma sanatındadır.

View Demo  •  Report Bug  •  Request Feature

Want to support oldventura, who brought us koyunkirpan, you can buy him a coffee.

Buy Me A Coffee

Getting Started

Deploy to Heroku with One-click

Deploy on Heroku

Local Installation

  1. Clone or download this repository in your project directory

    git clone https://github.com/KGBTR/koyunotlatan.git
    git clone [email protected]:KGBTR/koyunotlatan.git
    gh repo clone KGBTR/koyunotlatan
  2. Install dependencies

Before install dependencies may want to setup virtual enviroment:

python -m venv .venv
# For Sh, Bash, Zsh
. .venv/bin/activate
# For Fish
. .venv/bin/activate.fish

pip install -r requirements.txt

Define Reddit Bot Credentials

Use praw.ini

  • Rename praw.example.ini to praw.ini

    For MacOSX or Linux mv praw.example.ini praw.ini

    For Powershell Rename-Item praw.example.ini praw.ini For CMD rename praw.example.ini praw.ini

or

Use enviroment variables

Define BOT_ prefixed enviroment variables defined in .env.example

For CMD:

set BOT_USERNAME=BotUsername

For PowerShell:

$Env:BOT_USERNAME = "BotUsername"

For Bash and Zsh:

export BOT_USERNAME=BotUsername

For Fish:

set -Ux BOT_USERNAME BotUsername

Usage

python main.py
  • Collects total of 100 posts from hot and new.
  • Selects one random post
  • Collects keywords from this post and top comments
  • Searches for similar posts
  • Collects top 5 comments from similar posts
  • Compares keywords from these comments to find the best fit
  • Comments the best fit on the selected post

Comment on specific post:

python main.py -u <post_url>
python main.py --url <post_url>

or

python main.py -i <post_id>
python main.py --id <post_id>
  • Finds the submission on reddit by the post id
  • Finds the submission on reddit by the post url
  • Submission by url takes precedence over the submission by id.
  • Collects keywords from this post and top comments
  • Searches for similar posts
  • Collects top 5 comments from similar posts
  • Compares keywords from these comments to find the best fit
  • Comments the best fit on the selected post

How does it work?

At the beginning, I've tried several things for koyunkirpan. But none of the solutions were good enough. They were inconsistent, silly and not suited to the subreddit's context. Then, while I was drinking a few beers, I came up with a stupid solution that just worked. I called it "the koyunkirpan algorithm". Yes, koyunkirpan does not have artifical intelligence, does not use machine learning models and isn't an oracle machine :)

Trying to analyze text context was amazingly hard because of the diversity of the Turkish language. But the semantic of the text was always related to its syntax! So, I wrote a simple algorithm that searched through reddit for keywords in the source text. Here I've used a special search combination for reddit where keywords in the source text were combined together in some kind of a disjunctive normal form (DNF). The highest results always include most of the keywords in some sense. After that, the algorithm collects comments similar to the source text and collects their replies. After ranking the results, it just picks a reply and return this as the response to the source text. Simple but highly suited for a community!

Here's an example of the idea. Imagine you're asking me a question and I don't know the answer but I'm trying to look like I know the answer. So, I go to a university and wander around searching for people that ask similar questions to my original question. I listen to professors' answers, collect them, and then decide on an answer by ranking them. After that I return and just give you the selected answer.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

koyunkirpan is not a piece of software nor a product. It's a living piece of art that can be seen as the collective consciousness of users from r/KGBTR. Each day, koyunkirpan continues to amaze more people as he imitates comments made by real people.

Distributed under the GPLv3 license. See LICENSE for more information.

koyunotlatan's People

Contributors

asim-tahir avatar dependabot[bot] avatar oldventura avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.