ã£ã¦ã©ãããã®ï¼
æç®ç®¡çã½ããã¯ãpdf ãã¡ã¤ã«ã®ååã pmid.pdf ã«ããã®ãå¤ããã ãã©ãæä½æ¥ã¯ããã©ãã
=> 誰ãå¤æã¹ã¯ãªããããã
=> ktkr http://www.geocities.jp/researcherinus/perl1
=> ãã¾ã text æ½åºã§ããªãå ´åããã
=> èªåã§æ¸ããªãããã ãããï¼
=> Ruby 㧠pdf ãã text æ½åºã©ãããã®ãè¦ã¤ãããªãã£ã
Ruby㧠pdf ãã text æ½åºãã¦ã¿ã
ã¨ãããå¯ãåã« HMDT3çãèªãã§ããã RubyCocoa*1 㧠pdf ããã® text æ½åºãè¼ã£ã¦ãã
ã®ã§ãã¡ãã£ã¨ Nature ã¨ãã® pdf ãã text æ½åºã㦠doi ãæãåºããã試ãã¦ã¿ãã
#!/usr/bin/env ruby # # Created by mako on 2008-01-29. # What? # This_script.rb extracts text from pdf file # åèã«ãã URL # http://builder.japan.zdnet.com/sp/07leopard/story/0,3800082822,20360029-2,00.htm begin require 'osx/cocoa' OSX.require_framework 'Quartz' # window = OSX::NSWindow.alloc.initWithContentRect_styleMask_backing_defer([100, 100, 300, 300], 15, 2, 0) # window.makeKeyAndOrderFront(nil) # pdfview = OSX::PDFView.alloc.initWithFrame(window.contentView.frame) # window.contentView.addSubview(pdfview) pdf_files = ARGV pdf_files.each do |pdf_file| url = OSX::NSURL.fileURLWithPath("/Users/mako/#{pdf_file}") pdfdocument = OSX::PDFDocument.alloc.initWithURL(url) # pdfview.setDocument(pdfdocument) content = pdfdocument.string unless pdfdocument == nil puts ["#{pdf_file} => ", content.scan(/doi[\.|:].*/i)[0]].join("") unless content == nil end rescue Exception => e p e.message p e.backtrace end
Ruby ã§æ½åºã¨ãã¤ã¤ãã©ãã¿ã¦ã RubyCocoa w
require_framework 㧠Quartz ãã¦ãã®ã¯ãããã«å«ã¾ãã PDFKit ã使ãããããã
PDFKit ã«ã¤ãã¦ã¯ HMDT3çã®75ãã¼ã¸ä»è¿ãåç
§ã«ããã¨ãããæ¨ä¸ãããããã¨ãã
ã³ã¡ã³ãã¢ã¦ããã¦ãã®ã¯ãããã§ã¯ã¦ã¤ã³ãã¦ãå¼ã³åºãå¿
è¦ããªãããã
ã³ã¡ã³ãã¢ã¦ãããªãç¶æ
㧠Terminal ä¸ã«ã¦å®è¡ããã¨
window.makeKeyAndOrderFront(nil)
ã§ã¨ã©ã¼ã«ãªãï¼"NSInternalInconsistencyException - Error (1002) creating CGSWindow"ï¼ã
ãããã辺ã CocoaRepl ã ã¨åæã«ãã£ã¦ããã¦ããã®ããªï¼
ã¾ããRuby ã§ãã¾ã Cocoa ã使ããã¨å¬ããã:-)
Happy Macintosh Developing Time Third Edition Cocoaããã°ã©ãã®ããã®æè¡è§£èª¬æ¸
- ä½è : æ¨ä¸èª
- åºç社/ã¡ã¼ã«ã¼: ãã¼ã»ã¨ãã»ã¨ãæ°ç¤¾
- çºå£²æ¥: 2006/05/25
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- ã¯ãªãã¯: 26å
- ãã®ååãå«ãããã° (22件) ãè¦ã