⬆️ ⬇️

Programmer graphophilia

The last couple of days I have been immersed in the task of beautifully copying texts. I caught the idea when I read the post about the keyword graph for articles from the alexwolf website .

I also wanted to create such graphs for arbitrary texts and see how beautiful and interesting they can be. I'm not sure that everyone who is reading me now shares my programming understanding of beauty, but I still want to say that in my opinion it turned out beautiful and funny.





In order not to fence my bike for drawing graphs, I used the GraphViz package (you can also download it here ). The same utility uses Doxygen to draw beautiful graphs.

To prepare the data for the graph and simplify the work, I wrote a C ++ program ( CodeGraphMFC.rar , CodeGraphMFC_Sources.rar ).

The links can be downloaded and the program and source code (for VisualStudio 2005).

The program interface looks like this:

From TextGraphs


You can insert any text into it, click “Create graph” and it will create a graph of dependent words of this text.

Dependent words are words that are close to each other in the text (the maximum distance can be selected in the interface). You can also choose one of several methods for creating a graph.

The main rule: the closer the vertices of the resulting graph to each other, the more often the words in these vertices are found together in the text.

The program works only if GraphViz is installed and the path to it is registered correctly, and the default program for opening gif files must also be registered. it is the gifs that are created as a result.

Of the restrictions: for some reason, this package terribly slows down and flies out on large numbers of graph peaks. Therefore, the maximum number of different close words on which everything works is about 1000.



Today the program was ready and I played a little with it. The first results in the form of pictures can be viewed here: Web album .

')

For example, the beautiful graph of Pushkin’s poem Anchar:





In general, I must say that Russian graphs make beautiful graphs. Of the English is not so beautiful (although there the author is far from Pushkin):





And this is what a graph of a small class (C ++) looks like:





But a couple of fairly complex functions on a couple of screens (C ++):





And here is a beautiful graph of one of my posts about communism :





From interesting observations: beautiful graphs are obtained for texts, where there are very few repetitive words, or vice versa, where there are a lot of repetitions. At the same time, for poetry, for example, the most beautiful columns were obtained for the most beautiful poems. The articles also have a similar situation: the graph of the text of the user agreement looked frightening, and the light and simple articles are displayed in beautiful graphs.



Initially, I wanted to compare graphs for the same program, written in several different programming languages, but so far I have not found anything, it is more difficult to say “Hello, World”, but I myself am reluctant to write.

Does anyone have such programs for different languages ​​at least 30 lines?



I would be grateful if someone would download the program and collect their beautiful graphs.

Or advise how you can further develop this idea and what else to grab and compare?

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



All Articles