# -*- 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           github 1.0

github.setup        taku910 crfpp 0.58
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1
epoch               1
categories          math textproc
maintainers         nomaintainer

description         Yet Another CRF toolkit
long_description    CRF++ is a simple, customizable, and open source implementation \
                    of Conditional Random Fields (CRFs) for segmenting/labeling \
                    sequential data. \
                    CRF++ is designed for generic purpose and will be applied to \
                    a variety of NLP tasks, such as Named Entity Recognition, \
                    Information Extraction and Text Chunking.

license             LGPL-3+ BSD

homepage            https://taku910.github.io/crfpp/
master_sites        macports_distfiles
distname            CRF++-${version}
checksums           rmd160  3c70d129f06d88e13ece94d505dd417668f0a7bc \
                    sha256  9d1c0a994f25a5025cede5e1d3a687ec98cd4949bfb2aae13f2a873a13259cb2

patchfiles          patch-configure.diff \
                    patch-example.diff

depends_build       port:nkf

post-destroot {
    # install additional documents.
    set dest_doc ${destroot}${prefix}/share/doc/${name}
    xinstall -d  ${dest_doc}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS COPYING doc/index.html \
        ${dest_doc}
    # install examples.
    xinstall -d ${destroot}${prefix}/share/examples
    set ex                 ${prefix}/share/examples/${name}
    set dest_ex ${destroot}${ex}
    copy ${worksrcpath}/example ${dest_ex}
    copy ${worksrcpath}/sdk     ${dest_ex}
    # fix file pathes in exec.sh.
    set model_dir /var/tmp
    foreach task {JapaneseNE basenp chunking seg} {
        set dir ${ex}/${task}
        reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${dir}/exec.sh
        reinplace "s|@DIR@|${dir}|g"       ${destroot}${dir}/exec.sh
        reinplace "s|@MODEL@|${model_dir}/${name}.model|g" \
            ${destroot}${dir}/exec.sh
    }
    # convert to UTF-8
    foreach file {train.data test.data} {
        set path JapaneseNE/${file}
        system -W ${worksrcpath}/example "nkf -w ${path} > ${dest_ex}/${path}"
    }
}

livecheck.url       ${homepage}
livecheck.regex     CRF\\+\\+-(\[0-9.\]+)\\.
