robobruin / freebiestats

Automatically exported from code.google.com/p/freebiestats
0 stars 0 forks source link

HR stat (occasionally) doesn't show for certain players #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm not sure if it's a bug with the script or a bug with the stats source,
but I've noticed at least 3 times now when Ken Griffey Jr. hits a HR, it
will show 1 R, 0 HR, 1 RBI in the stats. I've also noticed this happening
for another player but I can't recall who it was at the moment.

Could the parsing be off because of 3 words in his name? I'm not sure what
else it could be. Thanks for the great script, even if you're unable to
reproduce/fix this problem, it's still a great tool.

Original issue reported on code.google.com by enthre...@gmail.com on 20 Jun 2007 at 10:00

GoogleCodeExporter commented 9 years ago
problem reproduced. will look into it.

Original comment by rod...@gmail.com on 21 Jun 2007 at 5:32

GoogleCodeExporter commented 9 years ago
Also, in addition to HR not showing, SB appears not to show as well. Tested it 
with
Gary Matthews Jr.

Original comment by enthre...@gmail.com on 25 Jun 2007 at 7:35

GoogleCodeExporter commented 9 years ago
Thanks. It's the same issue: the same function parses the boxscores for SB, 2B, 
3B,
HR, HBP, and SF. I'll try to fix it this week if I get a chance.

Original comment by rod...@gmail.com on 25 Jun 2007 at 2:07

GoogleCodeExporter commented 9 years ago
Also happens with B. McCann, since contains() is case sensitive, and Yahoo! 
likes to
spell his name as Mccann in the HR section.

Original comment by gopac...@gmail.com on 28 Aug 2007 at 3:39

GoogleCodeExporter commented 9 years ago
Any fix for this?

Original comment by cbas...@gmail.com on 21 May 2008 at 6:52

GoogleCodeExporter commented 9 years ago
Still an issue for last names with multiple upper-case characters.  Sample code 
below
can be used as a player-specific workaround.

The second and third lines are the workaround; just replace McLouth and/or 
DeRosa
with the players on your team(s).  I'm not 100% sure SB are still a problem, 
but HR
definitely are.  This is obviously an unwieldy solution, but it works in the 
short term.

    function getXBHorSB(type, playerName, document) {
    if (type=='HR' && playerName=='N McLouth') {playerName='N Mclouth';}
    if (type=='HR' && playerName=='M DeRosa') {playerName='M Derosa';}
        var nodes = xpath(document, "//td[@class='yspscores' and contains(.,'" + type
+ "') and contains(.,'" + playerName + "')]");
        var j = nodes.snapshotLength;
        var numStat = 0;

        if (j) {
            var statLine = nodes.snapshotItem(j - 1).textContent;
            //Remove everything in parentheses since that may create false matches
            statLine = statLine.replace(/\([^\)].+?\)/gi,'');
            if (statLine.indexOf(playerName) > -1) {
                var re = new RegExp(".*(" + playerName + " *\\d?).+", 'gi');
                statLine = statLine.replace(re, "$1");
                statLine = statLine.replace(/[^\d]+/, '');
                numStat = (statLine == '') ? 1 : statLine;
            }
        }
        return numStat;
    }

Original comment by ethanher...@gmail.com on 20 Apr 2009 at 3:25