#!/bin/sh
# hent-ordbank – Hent, pakk ut og gjer ordbankfilene klare til bruk.
#
# Copyright © 2008, 2009, 2010, 2012, 2018 Karl Ove Hufthammer <karl@huftis.org>.
#
#     This file is part of Ordbanken.
#
#     Ordbanken is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Gå til mappa med ordlistefilene.
cd ..

# Hent ned filene (manuelt) frå
#   https://www.nb.no/sprakbanken/show?serial=oai%3Anb.no%3Asbr-41&lang=nn
# og
#   https://www.nb.no/sprakbanken/show?serial=oai%3Anb.no%3Asbr-5&lang=nb


# Pakk ut filene (til undermapper).
tar xf *norsk_ordbank_nno_2012.tar.gz
tar xf *norsk_ordbank_nob_2005.tar.gz


# Flytt filene frå undermapper til hovudmappa,
# og skrift samantidig namn, slik at namna
# er like på nynorsk og bokmål.
for fil in *norsk_ordbank_nno_2012/*.txt
do
  mv $fil $(basename ${fil%_2012.txt}_nn.txt)
done
mv -f fullformer_nn.txt fullformsliste_nn.txt # For å ha same namneform som for bokmål
for fil in *norsk_ordbank_nob_2005/*.txt
do
  mv $fil $(basename ${fil%.txt}_nb.txt)
done


# Filene skal ikkje vera køyrbare …
chmod -x *.txt


# Fjern dei utpakka mappene og filene der.
rmdir *norsk_ordbank_nno_2012
rmdir *norsk_ordbank_nob_2005
