<?xml version="1.0"?>

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 -->

<!--

 Used by Maven only

 -->

<project name="mahout" default="core-job" basedir="../etc">
  <!-- Examples -->
  <property name="working.dir" value="work"/>
  <target name="check-files">
    <available file="temp/20news-18828.tar.gz" property="20news-18828.exists"/>
    <available file="${working.dir}/20news-18828" property="20news-18828.expanded"/>
    <!-- <available file="temp/enwiki-20070527-pages-articles.xml.bz2" property="enwiki.exists"/>
     <available file="temp/enwiki-20070527-pages-articles.xml" property="enwiki.expanded"/>
     -->
  </target>

  <target name="enwiki-files" depends="check-files">
        <mkdir dir="temp"/>
        <antcall target="get-enwiki"/>
        <antcall target="expand-enwiki"/>
    </target>

    <target name="get-enwiki" unless="enwiki.exists">
        <get src="http://people.apache.org/~gsingers/wikipedia/enwiki-20070527-pages-articles.xml.bz2"
             dest="temp/enwiki-20070527-pages-articles.xml.bz2"/>
    </target>

    <target name="expand-enwiki"  unless="enwiki.expanded">
        <bunzip2 src="temp/enwiki-20070527-pages-articles.xml.bz2" dest="temp"/>
    </target>


  <target name="get-20news-18828" unless="20news-18828.exists">
    <get src="http://people.csail.mit.edu/jrennie/20Newsgroups/20news-18828.tar.gz"
         dest="temp/20news-18828.tar.gz"/>

  </target>
  <target name="expand-20news-18828" unless="20news-18828.expanded">
    <gunzip src="temp/20news-18828.tar.gz" dest="temp"/>
    <untar src="temp/20news-18828.tar" dest="${working.dir}"/>
  </target>

  <target  name="get-20news" depends="check-files">
    <antcall target="get-20news-18828"/>
    <antcall target="expand-20news-18828"/>
  </target>

  <target name="extract-20news-18828" depends="check-files" unless="reuters.extracted">
    <mkdir dir="${working.dir}/20news-18828-collapse"/>
    <java classname="org.apache.mahout.classifier.bayes.PrepareTwentyNewsgroups" maxmemory="1024M" fork="true">
      <classpath refid="maven.test.classpath"/>
      <!--
      Input format is:
      inputDir outputDir label Analyzer character set
      -->
      <arg line="-p ${working.dir}/20news-18828/ -o ${working.dir}/20news-18828-collapse -a org.apache.lucene.analysis.standard.StandardAnalyzer -c UTF-8"/>
    </java>
  </target>

  <target name="get-files" depends="check-files"  description="Get and extract the 20 Newsgroups data">
    <mkdir dir="temp"/>
    <antcall target="get-20news"/>
     <!--<antcall target="enwiki-files"/> -->

     <!--<antcall target="extract-20news-18828"/> -->
  </target>


</project>
