Feb. 19th, 2013

juan_gandhi: (VP)
Screen Shot 2013-02-19 at 7.12.41 AM

интеллиджей 123.123, плагин 0.7.89, скала у меня здесь 2.8.1

и чо? ну не видит джара, хоть на эклипс переходи
juan_gandhi: (VP)
       try
        {
            if (header.startsWith( PDF_HEADER )) 
            {
                float pdfVersion = Float. parseFloat(
                        header.substring( PDF_HEADER.length(), Math.min( header.length(), PDF_HEADER .length()+3) ) );
                document.setVersion( pdfVersion );
            }
            else 
            {
                float pdfVersion = Float. parseFloat(
                        header.substring( FDF_HEADER.length(), Math.min( header.length(), FDF_HEADER.length()+3) ) );
                document.setVersion( pdfVersion );
            }
        }
        catch ( NumberFormatException e )
        {
            throw new IOException( "Error getting pdf version:" + e );
        } 


(from pdfbox library)
juan_gandhi: (VP)
def myFun(x: T) = {something...}

В алголе-68 такая вот фигня:
val mf = (myFun _)
называлась запроцедуриванием.
juan_gandhi: (VP)
Путин дал указание создать непротиворечивый и полный учебник истории.

Я предлагаю заодно уж создать непротиворечивый и полный учебник арифметики.
juan_gandhi: (VP)
  def extractTextFromImagesHiddenInPdf(pdf: File): String = {
    import OS._
    val fName = {
      val n = pdf.getName
      n.substring(0, n lastIndexOf '.')
    }
    def withExtension(x: String) = tempFile(fName, x)
    val png = withExtension("png")
    val tif = withExtension("tif")
    val noname = withExtension("")
    val txt = withExtension("txt")

    def exec(cmd: String) = Runtime.getRuntime.exec(cmd)
    def oops(txt: String, args: AnyRef*) = throw new IllegalStateException(txt.format(args:_*))

    exec("convert -density 600 %s -monochrome %s".format(pdf, png))
    val firstPage = if (png.exists) png else tempFile(fName + "-0", "png")
    if (!firstPage.exists) oops("Failed to create %s or %s", png, firstPage)

    exec("convert %s %s".format(firstPage, tif))
    if (!tif.exists) oops("Failed to create %s from %s", tif, firstPage)

    exec("tesseract %s %s".format(tif, noname))
    if (!txt.exists) oops("Failed to create %s from %s", txt, tif)

    Source.fromFile(txt).mkString
  }


(и в продакшен)

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

August 2025

S M T W T F S
      12
3456789
10 11 12 13141516
171819 20212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 25th, 2025 07:02 pm
Powered by Dreamwidth Studios