This site is supported by donations to The OEIS Foundation.
User:Enrique Pérez Herrero/OEIS2BibTeX
From OeisWiki
OEIS2BibTeX
This is a small PHP application to get fast BiTeX citation to OEIS sequences.
For more information, please visit:
Psychedelic Geometry: BibTeX Automatic OEIS Citations
To get citations by parameters supplied within the link, you can use for example, if you wish to cite the sequence A000340:
http://www.oeis2bibtex.netai.net/OEIS2BibTeX.php?sequence=A000340
OEIS2BibTeX PHP Code
<?php //Classic OEIS url. $oeis_url = "http://www.research.att.com/~njas/sequences/"; //Wiki OEIS url. $wiki_oeis_url = "http://oeis.org/wiki/"; function validate_sequence($s) { if (strlen($s)!=7) { print("ERROR-1: Bad Sequence Id length!"); return false; } $permitted = "0123456789"; for ($i=1; $i<strlen($s); $i++) { if (strpos($permitted, substr($s,$i,1))===false) { print("ERROR-2: Wrong characters on input string!"); return false; } } if (strpos("A", substr($s,0,1))===false) { print("ERROR-3: Sequence Id does not begin with A."); return false; } return true; } $OEIS_Id=strtoupper($_POST["sequence"]); if (!$OEIS_Id) $OEIS_Id=$_GET{sequence}; if(validate_sequence($OEIS_Id)) { $url1 = $oeis_url.$OEIS_Id; $url2 = $wiki_oeis_url.$OEIS_Id; //echo "$url1"."<br/>"; //echo "$url2"."<br/>"; $page_url = @fopen($url2, "r"); if($page_url) { $OEIS_Text=""; while(!feof($page_url)) { $OEIS_Text .= fgetss($page_url, 1024); } //echo $OEIS_Text."<br/>"."<br/>"; // Search the sequence description. $d1 = strpos($OEIS_Text,", search")+strlen(", search"); $d2 = strpos($OEIS_Text,"classic"); $OEIS_Description=trim(substr($OEIS_Text,$d1,$d2-$d1)); // Search the sequence Author. $a1 = strrpos($OEIS_Text,"Author")+strlen("Author"); $a2 = strrpos($OEIS_Text,"Retrieved"); $OEIS_Author=substr($OEIS_Text,$a1,$a2-$a1); //Removing Author´s email. $e = strpos($OEIS_Author,"("); $OEIS_Author=substr($OEIS_Author,1,$e-2); echo "@MISC{oeis".$OEIS_Id.",<br/>". "AUTHOR = {".$OEIS_Author."},<br/>". "TITLE = {The {O}n-{L}ine {E}ncyclopedia of {I}nteger {S}equences},<br/>". "HOWPUBLISHED = {\href{".$url2."}{".$OEIS_Id."}},<br/>". "MONTH={},<br/>". "YEAR ={},<br/>". "NOTE = {".$OEIS_Description."}<br/>}"; } else {print("ERROR4-Sequence does not exists");} } @fclose($page_url); ?>
OEIS2BibTeX KNOWN ISSUES
- The code can not find the AUTHOR when there are more than one.
- The code can not find the AUTHOR when no email is supplied.
- MONTH and YEAR are not implemented.