# -*- 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
# $Id: Portfile 102049 2013-01-26 12:38:28Z hum@macports.org $

PortSystem          1.0

name                jdepp
version             2013-01-23
categories          textproc japanese
maintainers         hum openmaintainer

description         C++ implementation of Japanese Dependency Parsers

long_description    J.DepP is a C++ implementation of Japanese dependency \
                    parsing algorithms. The parser takes a raw sentence as input \
                    and performs word segmentation, POS tagging (thanks to MeCab), \
                    bunsetsu chunking and dependency parsing. J.DepP is meant \
                    for those who want to parse massive texts (e.g., entire blog \
                    feeds) efficiently with state-of-the-art parsing accuracy.

homepage            http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/jdepp/
platforms           darwin
license             {GPL-2 LGPL-2.1}

master_sites        ${homepage}
checksums           ${distname}${extract.suffix} \
                    rmd160  cb074e8ea1648ea2e3eb1262f6d2d0e1f7a5e5c5 \
                    sha256  9c6ea9e3be05d4074e9a0b427b02b284e23a8649fcc1b36f5f64f30fd43f19cf

patchfiles          patch-configure.diff

depends_lib         port:mecab-base \
                    port:mecab-jumandic-utf8

configure.args      --enable-standalone

variant knbc conflicts kyoto kyoto_partial description {Train a parser wht KNBC (Kyoto-University and NTT Blog Corpus)} {
    depends_build-append  port:KNBC

    configure.args-append --with-corpus=knbc

    build.target          model
    build.args-append     CORPUS_DIR=${prefix}/share/KNBC
}

variant kyoto_partial conflicts kyoto knbc description {Train a parser with Kyoto-University Text Corpus annotation without Mainichi news articles} {
    set kyoto_corpus      KyotoCorpus4.0
    set corpus_distfile   ${kyoto_corpus}${extract.suffix}
    distfiles-append      ${corpus_distfile}:corpus
    master_sites-append   http://nlp.ist.i.kyoto-u.ac.jp/nl-resource/corpus/:corpus
    checksums-append      ${corpus_distfile} \
                          rmd160  9c8212d939b7112a79aff30ab0880f94c3ee9b48 \
                          sha256  6fe4f7bac19e192f7545c4de0c765f690a524c7611191e2af9be031d4923871f

    configure.args-append --with-corpus=kyoto-partial \
                          --enable-autopos-train=no

    build.target          model
    build.args-append     CORPUS_DIR=${workpath}/${kyoto_corpus}
}

# To use the complete kyoto corpus with +kyoto variant, users must put their data into the following directory.
set kyoto_dir       /tmp/KyotoCorpus4.0

variant kyoto conflicts kyoto_partial knbc description {Train a parser with Kyoto-University Text Corpus} {
    if {[file exists ${kyoto_dir}]} {
        build.target          model
        build.args-append     CORPUS_DIR=${kyoto_dir}
    } else {
        pre-fetch {
            ui_error "To train a parser with Kyoto Corpus, please put the files in ${kyoto_dir}"
            return -code error "Kyoto Corpus is not available at ${kyoto_dir}"
        }
    }
}

variant ipadic conflicts naistjdic description {Build a parser with auto POSs given by MeCab/ipadic} {
    depends_lib-delete    port:mecab-jumandic-utf8
    depends_lib-append    port:mecab-ipadic-utf8

    configure.args-append --with-mecab-dict=IPA
}

variant naistjdic conflicts ipadic description {Build a parser with auto POSs given by MeCab/NAIST-jdic} {
    depends_lib-delete    port:mecab-jumandic-utf8
    depends_lib-append    port:mecab-naist-jdic-utf8

    configure.args-append --with-mecab-dict=NAIST-J
}

if {![variant_isset kyoto] && ![variant_isset kyoto_partial]} {
    default_variants +knbc
}

post-destroot {
    set doc_dir ${destroot}${prefix}/share/doc/${name}
    file mkdir ${doc_dir}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS COPYING GPL LGPL README TODO \
        ${doc_dir}
}

livecheck.type      regex
livecheck.regex     ${name}-(\\d+-\\d+-\\d+)\\.
