@@ -53,16 +53,15 @@ object WikiClade {
5353 val path = " /wiki/" + name.replaceAll(" " , " _" )
5454 val url = baseUrl + path
5555 val docOpt = WikiProxy .fetchPage(url)
56- // TODO Check for paraphyly
57- // TODO Check for polyphyly
58- val taxPathOpt = getTaxoboxLink(docOpt)
59- val taxDocOpt = getDoc(taxPathOpt)
6056 val title = getTitle(Some (path))
57+ val isBadger = title.contains(" Badger - Wikipedia" ) // yes, I'm hard-coding badgers. I blame Wikipedia.
58+ val taxPathOpt = getTaxoboxLink(if (isBadger) " Melinae" else name, docOpt)
59+ val taxDocOpt = getDoc(taxPathOpt)
6160 val ttitle = getTitle(taxoboxGetPageLink(taxDocOpt))
6261 title match {
6362 case None => new WikiPageClade (name, taxPathOpt, 0 )
6463 case Some (_) =>
65- if (title == ttitle) new WikiTaxoboxClade (name, taxPathOpt, priorityOverride = 0 )
64+ if (title == ttitle || isBadger ) new WikiTaxoboxClade (name, taxPathOpt, priorityOverride = 0 )
6665 else new WikiPageClade (name, Some (path), 0 )
6766 }
6867 }
@@ -96,7 +95,15 @@ object WikiClade {
9695 case None => new Elements ()
9796 }
9897
99- private def getTaxoboxLink (docOpt : Option [Document ]): Option [String ] = {
98+ private def getTaxoboxLink (name : String , docOpt : Option [Document ]): Option [String ] = {
99+ val possibleTaxPath = " /wiki/Template:Taxonomy/" + name.replaceAll(" " , " _" )
100+ getTitle(Some (possibleTaxPath)) match {
101+ case Some (_) => Some (possibleTaxPath)
102+ case None => getTaxoboxLinkFromEditButton(docOpt)
103+ }
104+ }
105+
106+ private def getTaxoboxLinkFromEditButton (docOpt : Option [Document ]): Option [String ] = {
100107 val elements = getInfoTable(docOpt)
101108 def iter (i : Int ): Option [String ] = {
102109 def iter2 (as : Elements , j : Int ): Option [String ] = {
0 commit comments