{"action":"created","issue":{"url":"https://api.github.com/repos/github/linguist/issues/1626","repository_url":"https://api.github.com/repos/github/linguist","labels_url":"https://api.github.com/repos/github/linguist/issues/1626/labels{/name}","comments_url":"https://api.github.com/repos/github/linguist/issues/1626/comments","events_url":"https://api.github.com/repos/github/linguist/issues/1626/events","html_url":"https://github.com/github/linguist/issues/1626","id":46609449,"node_id":"MDU6SXNzdWU0NjYwOTQ0OQ==","number":1626,"title":"Fixing C/C++/Objective-C classifications","user":{"login":"arfon","id":4483,"node_id":"MDQ6VXNlcjQ0ODM=","avatar_url":"https://avatars1.githubusercontent.com/u/4483?v=4","gravatar_id":"","url":"https://api.github.com/users/arfon","html_url":"https://github.com/arfon","followers_url":"https://api.github.com/users/arfon/followers","following_url":"https://api.github.com/users/arfon/following{/other_user}","gists_url":"https://api.github.com/users/arfon/gists{/gist_id}","starred_url":"https://api.github.com/users/arfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arfon/subscriptions","organizations_url":"https://api.github.com/users/arfon/orgs","repos_url":"https://api.github.com/users/arfon/repos","events_url":"https://api.github.com/users/arfon/events{/privacy}","received_events_url":"https://api.github.com/users/arfon/received_events","type":"User","site_admin":false},"labels":[{"id":94684392,"node_id":"MDU6TGFiZWw5NDY4NDM5Mg==","url":"https://api.github.com/repos/github/linguist/labels/Help%20Wanted","name":"Help Wanted","color":"cced98","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":110,"created_at":"2014-10-23T10:22:21Z","updated_at":"2018-07-09T15:49:00Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"A fair fraction of the outstanding issues with Linguist mis-classifications are to do with C, C++, Objective-C and any other languages that use `.m` or `.h` as extension.\n\nWhile it's possible we can see further improvements by increasing our samples for the Bayesian classifier I'm pretty convinced we need to craft a few reliable heuristics to shortcut the classifier.\n\nWe currently have the following in [`heuristics.rb`](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb#L36-L41) but it's not being called. \n\n``` ruby\ndef self.disambiguate_c(data, languages)\n  matches = []\n  matches << Language[\"Objective-C\"] if data.include?(\"@interface\")\n  matches << Language[\"C++\"] if data.include?(\"#include <cstdint>\")\n  matches\nend\n```\n\n@DX-MON had a good go at this in #1036 but at the time we didn't have a good way to benchmark the effects of these changes. With the new [benchmarks](https://github.com/github/linguist/blob/master/Rakefile#L36) we are now in a good place to tackle this problem.\n\nThe [current heuristic](https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb#L36-L41) is deliberately limited in scope, that's because any heuristics we define should be accurate, simple to understand and fast.\n\nBasically I'm asking for some help with this. I'm more than happy to grab a bunch (1000s) of files to test any potential changes on. Questions for you all:\n1. How do we feel about #1036 - I'd love to see a case for `C` in that `disambiguate_c` method too if possible. \n2. #1036 is matching on a [bunch of keywords](https://github.com/github/linguist/pull/1036/files#diff-e56a8d50b1a75fc4212ffb3504faa007R43) - are all of these necessary? Are we potentially sacrificing accuracy for completeness?\n3. Are there any good heuristics for pure C code?\n"},"comment":{"url":"https://api.github.com/repos/github/linguist/issues/comments/403526261","html_url":"https://github.com/github/linguist/issues/1626#issuecomment-403526261","issue_url":"https://api.github.com/repos/github/linguist/issues/1626","id":403526261,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzUyNjI2MQ==","user":{"login":"pchaigno","id":1764210,"node_id":"MDQ6VXNlcjE3NjQyMTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1764210?v=4","gravatar_id":"","url":"https://api.github.com/users/pchaigno","html_url":"https://github.com/pchaigno","followers_url":"https://api.github.com/users/pchaigno/followers","following_url":"https://api.github.com/users/pchaigno/following{/other_user}","gists_url":"https://api.github.com/users/pchaigno/gists{/gist_id}","starred_url":"https://api.github.com/users/pchaigno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pchaigno/subscriptions","organizations_url":"https://api.github.com/users/pchaigno/orgs","repos_url":"https://api.github.com/users/pchaigno/repos","events_url":"https://api.github.com/users/pchaigno/events{/privacy}","received_events_url":"https://api.github.com/users/pchaigno/received_events","type":"User","site_admin":false},"created_at":"2018-07-09T15:49:00Z","updated_at":"2018-07-09T15:49:00Z","author_association":"COLLABORATOR","body":"@smola #4025 is near-ready, only missing a test case. I'll close it if it isn't updated in a week or will try to add it myself.\r\n#3585 is on me; I had completely forgot about it. I still need to run some benchmark, but other than that, it should be possible to merge it soon (unless the number are all wrong).\r\n\r\nOnce those pull requests are merged, I think we should look for other ways to address the remaining issues with the `.h` extension, if any. We try to make the users' experience as smooth as possible, and for this reason, we follow usage and not specifications (or even, sometimes, logic). By all accounts, a large number of users still have `.h` C++ files so I don't think we should just consider all `.h` files C. Other approaches are possible, though at the cost of a large changes in how we process files in Linguist. We can look into these once the heuristic rules have been improved."}}
{"actor":{"display_login":"pchaigno"}}