2013-07-29 2 views
2

matlab에서 DOI (Digital Object Identifier)를 http://www.crossref.org으로 전송하여 bibtex 데이터를 가져 오려고합니다. this 소스에matlab에서 DOI를 전송하여 crossref에서 bibtex 데이터를 검색합니다.

curl -LH "Accept: text/bibliography; style=bibtex" http://dx.doi.org/10.1038/nrd842 

을 기반 :

crossref API는 다음과 같이 제안합니다. 내가 루비 바위를 들었어요하지만

open("http://dx.doi.org/10.1038/nrd842","Accept" => "text/bibliography; style=bibtex"){|f| f.each {|line| print line}} 

내가 MATLAB에서이 작업을 수행하려면 어떻게 루비 메시지를 번역하거나 crossref 명령을 해석하는 단서가 없다 :

here에서 또 다른 예는 ruby에 다음과 같은 제안 .

clear 
clc 

doi = '10.1038/nrd842'; 

URL_PATTERN = 'http://dx.doi.org/%s'; 
fetchurl = sprintf(URL_PATTERN,doi); 

numinputs = 1; 

www = java.net.URL(fetchurl); 

is = www.openStream; 

%Read stream of data 
isr = java.io.InputStreamReader(is); 
br = java.io.BufferedReader(isr); 

%Parse return data 
retdat = []; 
next_line = toCharArray(br.readLine)'; %First line contains headings, determine length 

%Loop through data 

while ischar(next_line) 
    retdat = [retdat, 13, next_line]; 
    tmp = br.readLine; 
    try 
    next_line = toCharArray(tmp)'; 
    if strcmp(next_line,'M END') 
     next_line = []; 
     break 
    end 
    catch 
    break; 
    end 
end 


%Cleanup java objects 
br.close; 
isr.close; 
is.close; 

도움말 뭔가 MATLAB에 루비 문을 번역 :

다음

포맷, 내가하여 BibTex crossref과 (가변 retdat)에 XML 데이터를 검색,하지만하는 도이을 보내 지금까지 무엇을 가지고 그와 같은 스크립트를 사용하여 보낼 수있는 크로스 레퍼런스와의 통신을 확립하기 위해 크게 감사하겠습니다.

편집 :> (또한, 루비의 아무 소용이, 그 문제를 해결하지만, "MATLAB"이 아니므 :.

추가 제약 (다시 적어도 R14에) 코드의 이전 버전과의 호환성을 포함 이 솔루션은 system('ruby script.rb')를 통해 MATLAB에서 루비를 호출하는 방법에 대한 here를 참조하십시오.

+0

로 대체되었을 때 상황이 일을 왜 대신 원시 자바 ['urlread'] (http://www.mathworks.com/help/matlab/ref /urlread.html)? – horchler

+0

그것은 역사적인 것입니다 : 코드는 다른 앱에서 빌려 왔습니다. –

+0

요청 헤더 및 기타 세부 정보를 설정하려면 [참조하십시오] (http://undocumentedmatlab.com/blog/expanding-urlreads-capabilities/). – horchler

답변

0

는 user2034006에서 대답 낳는다 솔루션 경로. urlread가 수정 될 때 다음 스크립트는 작동합니다

URL_PATTERN = 'http://dx.doi.org/%s'; 
doi = '10.1038/nrd842'; 
fetchurl = sprintf(URL_PATTERN,doi); 
method = 'post'; 
params= {}; 
[string,status] = urlread(fetchurl,method,params); 

urlread의 수정 user2034006의 제안과 동일하지 않습니다. urlread의 라인

urlConnection.setRequestProperty('Content-Type','application/x-www-form-urlencoded'); 

urlConnection.setRequestProperty('Accept','text/bibliography; style=bibtex'); 
1

쉽게 당신이 필요로하는 무엇을 urlread 편집 할 수 있습니다. 나는 인해 저작권에 내 수정 urlread 기능 코드를 게시하지 않습니다. urlread에서

, (내 위치는 C : \ Program Files \ MATLAB \ R2012입니다. \ 도구 상자 \ MATLAB은 iofun는 urlread.m), 가장 우아한 솔루션으로 \ \ : 내가 추가

직전에 "%는 연결에서 데이터를 읽습니다."

urlConnection.setRequestProperty('Accept','text/bibliography; style=bibtex'); 
+0

귀하의 제안에 따라 제 대답을 참조하십시오. 당신의 도움을 주셔서 대단히 감사합니다!! –

관련 문제