How does Github calculate the proportion of the languages in the project code?

Viewed 1004

Projects on GitHub have a Languages graph which calculates the proportion of the particular programming language in the project.

enter image description here

I would naively think, that the most straightforward approach is to traverse over all files with a given extension in the project and sum the number of lines (words or symbols), and then this sum for a particular language is divided by the sum for all languages.

For example if the projects contains .py files with [200, 100, 500] lines, and the .cpp files with [800, 1600] lines, I would expect that the calculated ratio would be :

  • 66.6% C++
  • 33.3% Python

However, for the image attached, there is much more code (lines/words) in the .py files, than in the .ipynb.

Therefore, there must be a different strategy to calculate the proportion. How exactly?

1 Answers
Related