📜 ⬆️ ⬇️

How we use the Giphy API for thematic gifs in a football status bot

Our free time analytics department grows a bot that finds interesting patterns in football statistics and writes statuses about it on our Sports.ru . Robot name is FRED, it turns out like this:

image

The creativity of the robot is not yet diverse (only a couple dozen types of facts), but the framework is ready. The basic model is as follows:

1. Once a hour, a Python script is launched that analyzes the next football matches, if any.
')
2. The script considers all possible facts for teams playing in selected matches, using reports on teams and players from our base.

Each type of facts has its own function of interest, which depends on the content of the fact (goals are more interesting than cards and substitutions), its extremes (score ten games in a row more interesting than five) and the popularity of teams and tournaments on the site.

3. Of all the facts, three of the most interesting are selected, which are fasted via the API to the Sports.ru status tape and to Twitter. Only very interesting facts can get into the general Sports.ru feeds (with all new statuses), the rest can only be seen by subscribers.

Improvement with the help of "dobivok"

The first experiments of the robot looked unconvincing: monotonous facts looked boring (especially since at times Fred climbs somewhere in Gibraltar football). He definitely lacked emotion and diversity.

To begin with, we decided to add “punchline” to the facts: the word “finishing off” at the end, emphasizing the emotion of the statement. This style of football was popularized by Opta, which supplies statistics including Sports.ru. Of course, Opta accounts are led by real people .

We have nine categories of possible punchlines. Each type of fact has its own category, but sometimes supplements and other types are taken, so an additional comic effect is created. Script writers know that an interesting scene is one in which what is not expected of the audience, but at the same time preserves the integrity of the world of the work. The larger the gap between expectation and real outcome, the more interesting. The robot, of course, does not post completely random words (then the integrity disappears and the mechanical nature of the statement becomes too obvious), but sometimes writing “What is the point?” After the phrase about the series of victories “Spartacus” is quite funny.

Gifs enhancement

But we wanted to make the robot even more interesting - if only because it is not yet smart enough to entertain only with statistics. It is convenient to look at gifs in statuses on Sports.ru, so we decided to illustrate the facts with their help. Thematic gifs, however, are almost impossible to find (there are almost no even about players of the Russian championship), so we turned again to the emotions of statements.

The fixed list of gifs is similar to the dictionary of punchlines, however, I didn’t want to do so. Gifs quickly become boring, collect them for a long time and need to be changed regularly - this means that such a solution does not scale well (ideally, the robot should work for different countries and in different languages). Fortunately, there is a Giphy project with a large base of well-designed and well-suited gifs - and, which is especially nice, Giphy has its own free API .

Now the robot, posting the status, accompanies it with something random from fresh gifs - for example, with tags fail or wtf . The combination of fact, punchline and gifs makes it possible to more often generate statuses that turn out to be statements in their own right. For example, such :

image

In the worst case, the robot, as if an SMM manager broke the chain, decorates the ribbon with random gifs. Perhaps, with the development of the actual extraction of patterns, we will give up additional decorations, but so far the gifs stimulate well at least the staff involved in the project.

image

What are we planning to do with Fred next:

1. To seriously expand the number of possible facts.

2. Use for training the bot activity of its subscribers, who comment, like and repost successful statuses.

3. To multiply it for our projects in different countries, taking into account regional peculiarities.

We are happy to answer questions and accept suggestions for the development of the status bot.

Source: https://habr.com/ru/post/236195/


All Articles