public function createProceeding($data) { try { $bookData = WebAPI::searchBookData($data['ISBN'][0]); } catch (CException $e) { $bookData = null; } $proc = new Proceeding(); $proc->type = $data['type']; $proc->authors = $data['author']; $proc->year = $data['issued']['date-parts'][0][0]; $proc->title = $data['title'][0]; $proc->proc_name = StringHelper::titleCase($data['container-title'][0]); $proc->pages = null; // sigh. no info available if ($bookData !== null) { $proc->pub = $bookData['publisher']; $city = explode(",", $bookData['city']); $proc->pub_city = reset($city); $proc->pub_city = preg_replace("/[^A-Za-z0-9 \\-']/", "", $proc->pub_city); // additional filtering $proc->pub_country = WebAPI::searchCityData($proc->pub_city); // editors, con_date, con_city uses Stanford NER // sometimes editors in author, sometimes in title~ $combined = $bookData['author'] . ' ' . $bookData['title']; $ner_result = StringHelper::NER($combined); $proc->editors = StringHelper::parseNerPerson($ner_result); $proc->con_date = StringHelper::parseNerDate($ner_result); $proc->con_city = StringHelper::parseNerLocation($ner_result); } else { $proc->pub = $data['publisher']; } return $proc; }
public function actionIsbn() { $isbn = Yii::app()->request->getParam('isbn'); $data = WebAPI::searchBookData($isbn); $book = new Book(); $book->authors = rtrim($data['author'], "."); $book->year = $data['year']; $book->title = str_replace(" : ", ": ", $data['title']); $book->edition = filter_var($data['ed'], FILTER_SANITIZE_NUMBER_INT); $city = explode(",", $data['city']); $book->pub_city = reset($city); $book->pub_country = WebAPI::searchCityData($book->pub_city); $book->pub = str_replace("/", ", ", $data['publisher']); $this->renderJSON((array) $book); }