#!/bin/sh
#

rm /tmp/dbjoinweight* > /dev/null 2>&1
cat WEIGHT.txt | sed -e "s/1tsp/tsp/" | join -j 1 -t'^' - FOOD_DES.txt | cut -f1-5,8-9 -d'^' | tr -d '~' | preprocess/dbjw 1 | sort -n -t"^" +0 +1 +4 | preprocess/dbjw 2 | preprocess/dbjw 3 > /tmp/dbjoinweightp
cat /tmp/dbjoinweightp | cut -f1,3-5 -d"^" > /tmp/dbjoinweightq
cat FOOD_DES.txt | tr -d '~' | join -v 1 -j 1 -t'^' - /tmp/dbjoinweightq | cut -f1-3 -d"^" | sort -n -t"^" +1 +0 | preprocess/dbjw 4 >> /tmp/dbjoinweightp
cat /tmp/dbjoinweightp | preprocess/dbjw 5 | sort -n +0 | cut -f1,3-5 -d"^" > /tmp/dbjoinweight9
cat /tmp/dbjoinweightp | sort -n +0 | cut -f1,3-5 -d"^" > /tmp/dbjoinweight
preprocess/dbjoinwlib
cp /tmp/dbjoinwlib raw.data/WEIGHT.lib

