# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           java 1.0

name                mallet
version             2.0.8
revision            1
categories          math java
maintainers         nomaintainer

description         MAchine Learning for LanguagE Toolkit (MALLET)
long_description    MALLET is a Java-based package for statistical natural \
                    language processing, document classification, clustering, \
                    topic modeling, information extraction, and other machine \
                    learning applications to text.

homepage            http://mallet.cs.umass.edu/
platforms           darwin
supported_archs     noarch
license             CPL-1

master_sites        http://mallet.cs.umass.edu/dist/
checksums           rmd160  3007048a099bd5870d8566c2b6b9b691f85048ba \
                    sha256  5b2d6fb9bcf600b1836b09881821a6781dd45a7d3032e61d7500d027a5b34faf \
                    size    14868234

# JDK port to install if required java not found
java.fallback       openjdk13

patchfiles          patch-mallet.diff

use_configure       no

build {}

destroot {
    # install jar files
    xinstall -m 0755 -d ${destroot}${prefix}/share/java
    set malletdir ${prefix}/share/java/${distname}
    copy ${worksrcpath}/dist ${destroot}${malletdir}
    fs-traverse f ${destroot}${malletdir} {
        if {[file isfile ${f}]} {
            file attributes ${f} -permissions a+r
        } elseif {[file isdirectory ${f}]} {
            file attributes ${f} -permissions a+rx
        }
    }
    
    # install the mallet command; set the malletdir variable
    xinstall -m 0755 ${worksrcpath}/bin/mallet ${destroot}${prefix}/bin
    reinplace "s|@MALLETDIR@|${malletdir}|" \
        ${destroot}${prefix}/bin/mallet

    # install additional documents
    set dest_doc ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${dest_doc}
    xinstall -m 0644 ${worksrcpath}/LICENSE ${dest_doc}

    # install examples
    xinstall -d ${destroot}${prefix}/share/examples
    set dest_ex ${destroot}${prefix}/share/examples/${name}
    copy ${worksrcpath}/sample-data ${dest_ex}
    fs-traverse f ${dest_ex} {
        if {[file isfile ${f}]} {
            file attributes ${f} -permissions a+r
        } elseif {[file isdirectory ${f}]} {
            file attributes ${f} -permissions a+rx
        }
    }
}
    
livecheck.type      regex
livecheck.url       http://mallet.cs.umass.edu/download.php
livecheck.regex     ${name}-(\[\\d\\.\]+)\\.tar