Skip to content

Commit

Permalink
EticaAI/numerordinatio#5: 999999999/999999999.sh changed_recently
Browse files Browse the repository at this point in the history
  • Loading branch information
eticaaibot committed Jan 9, 2022
1 parent 9497b20 commit fb5a9e8
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 11 deletions.
5 changes: 4 additions & 1 deletion 999999999/0.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ bash "${ROOTDIR}/999999999/1603.47.639.3.sh"

bash "${ROOTDIR}/999999999/1603.45.49.sh"

bash "${ROOTDIR}/999999999/1603.45.16.sh"
bash "${ROOTDIR}/999999999/1603.45.16.sh"

# For a list of POSIX utils _granted_ to be installed everywhere:
# @see https://en.wikipedia.org/wiki/List_of_Unix_commands
79 changes: 69 additions & 10 deletions 999999999/1603.47.639.3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,23 @@ ROOTDIR="$(pwd)"
# - https://proxy.hxlstandard.org/data.csv?tagger-match-all=on&tagger-01-header=id&tagger-01-tag=%23vocab+%2Bid+%2Bv_iso6393_3letter&tagger-02-header=part2b&tagger-02-tag=%23vocab+%2Bcode+%2Bv_iso3692_3letter+%2Bz_bibliographic&tagger-03-header=part2t&tagger-03-tag=%23vocab+%2Bcode+%2Bv_3692_3letter+%2Bz_terminology&tagger-04-header=part1&tagger-04-tag=%23vocab+%2Bcode+%2Bv_6391&tagger-05-header=scope&tagger-05-tag=%23status&tagger-06-header=language_type&tagger-06-tag=%23vocab+%2Btype&tagger-07-header=ref_name&tagger-07-tag=%23description+%2Bname+%2Bi_en&tagger-08-header=comment&tagger-08-tag=%23description+%2Bcomment+%2Bi_en&url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1mlc3zLkdgGRMOts36PiK2eFrMazgidKs%2Fview%3Fusp%3Dsharing&header-row=1&dest=data_view

DATA_ISO_639_3_TAB="https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3.tab"
DATA_ISO_639_3_CSV="https://proxy.hxlstandard.org/data.csv?tagger-match-all=on&tagger-01-header=id&tagger-01-tag=%23vocab+%2Bid+%2Bv_iso6393_3letter&tagger-02-header=part2b&tagger-02-tag=%23vocab+%2Bcode+%2Bv_iso3692_3letter+%2Bz_bibliographic&tagger-03-header=part2t&tagger-03-tag=%23vocab+%2Bcode+%2Bv_3692_3letter+%2Bz_terminology&tagger-04-header=part1&tagger-04-tag=%23vocab+%2Bcode+%2Bv_6391&tagger-05-header=scope&tagger-05-tag=%23status&tagger-06-header=language_type&tagger-06-tag=%23vocab+%2Btype&tagger-07-header=ref_name&tagger-07-tag=%23description+%2Bname+%2Bi_en&tagger-08-header=comment&tagger-08-tag=%23description+%2Bcomment+%2Bi_en&url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1mlc3zLkdgGRMOts36PiK2eFrMazgidKs%2Fview%3Fusp%3Dsharing&header-row=1&dest=data_view"
DATA_ISO_639_3_CSV="https://proxy.hxlstandard.org/data.csv?tagger-match-all=on&tagger-01-header=id&tagger-01-tag=%23vocab+%2Bid+%2Bv_iso6393_3letter&tagger-02-header=part2b&tagger-02-tag=%23vocab+%2Bcode+%2Bv_iso3692a3+%2Bz_bibliographic&tagger-03-header=part2t&tagger-03-tag=%23vocab+%2Bcode+%2Bv_3692_3letter+%2Bz_terminology&tagger-04-header=part1&tagger-04-tag=%23vocab+%2Bcode+%2Bv_6391&tagger-05-header=scope&tagger-05-tag=%23status&tagger-06-header=language_type&tagger-06-tag=%23vocab+%2Btype&tagger-07-header=ref_name&tagger-07-tag=%23description+%2Bname+%2Bi_en&tagger-08-header=comment&tagger-08-tag=%23description+%2Bcomment+%2Bi_en&url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1mlc3zLkdgGRMOts36PiK2eFrMazgidKs%2Fview%3Fusp%3Dsharing&header-row=1&dest=data_view"

# shellcheck source=999999999.sh
. "$ROOTDIR"/999999999/999999999.sh

#######################################
# Download external source files
# Download external source files.
# Note: using raw tab file for now.
#
# Globals:
# ROOTDIR
# DATA_ISO_639_3_CSV
# DATA_ISO_639_3_TAB
# Arguments:
# None
#######################################
bootstrap_999999_1603_47_639_3_fetch_data() {
bootstrap_999999_1603_47_639_3_fetch_data_hxlated() {

# An Non HXLated version
if [ ! -f "${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.tab" ]; then
Expand Down Expand Up @@ -79,14 +81,29 @@ bootstrap_999999_1603_47_639_3_fetch_data() {
else
echo "Cached already is valid. Ok."
fi
}

# echo "is_valid $is_valid"
# echo "is_valid2 $is_valid2"

# hxlclean 999999/1603/47/639/3/1603.47.639.3.hxl.csv > 999999/1603/47/639/3/1603.47.639.3.TEST.hxl.csv
# hxlclean 999999/1603/47/639/3/1603.47.639.3.TEST.hxl.csv > 999999/1603/47/639/3/1603.47.639.3.TEST3333.hxl.csv
#######################################
# Download external source files
# Note: using raw tab file for now.
#
# Globals:
# ROOTDIR
# DATA_ISO_639_3_CSV
# DATA_ISO_639_3_TAB
# Arguments:
# None
#######################################
bootstrap_999999_1603_47_639_3_fetch_data_raw() {

# csvclean -n 999999/1603/47/639/3/1603.47.639.3.hxl.csv
# An Non HXLated version
if [ ! -f "${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.tab" ]; then
wget -qO- "$DATA_ISO_639_3_TAB" > "${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.tab"
touch "${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.tab.CHANGED"
else
echo "Cached: ${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.hxl.csv"
fi
}

#######################################
Expand All @@ -100,7 +117,7 @@ bootstrap_999999_1603_47_639_3_fetch_data() {
# Outputs:
# 999999/999999/1603.47.639.3.tsv
#######################################
bootstrap_999999_1603_47_639_3() {
bootstrap_999999_1603_47_639_3_old() {
hxladd \
--before --spec="#x_item+lower={{#vocab+code+v_6391}}" \
--before --spec="#x_item+upper={{#vocab+code+v_6391}}" \
Expand All @@ -121,7 +138,49 @@ bootstrap_999999_1603_47_639_3() {
> "${ROOTDIR}/999999/999999/1603.47.639.3.tsv"
}

bootstrap_999999_1603_47_639_3_fetch_data
#######################################
# Transform 999999/1603/47/639/3/1603.47.639.3.tab into
# 999999/999999/1603.47.639.3.tsv
#
# Globals:
# ROOTDIR
# Arguments:
# None
# Outputs:
# 999999/999999/1603.47.639.3.tsv
#######################################
bootstrap_999999_1603_47_639_3() {
source_file="${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.tab"
# target_file="${ROOTDIR}/999999/999999/1603.47.639.3.tsv"
target_file="${ROOTDIR}/999999/999999/1603.47.639.3-neo.tsv"

# if [ -z "$(changed_recently "$source_file")" ]; then return 0; fi

echo "$0 TODO..."

# if [ ! -f "${ROOTDIR}/999999/1603/47/639/3/1603.47.639.3.tab.CHANGED" ]; then
# echo "$0 no refrech "
# fi
# 999999/1603/47/639/3/1603.47.639.3.tab
}

### Note: using raw data fetch for now
# bootstrap_999999_1603_47_639_3_fetch_data_hxlated
# bootstrap_999999_1603_47_639_3_old

bootstrap_999999_1603_47_639_3_fetch_data_raw
bootstrap_999999_1603_47_639_3


# find 999999/1603/47/639/3/1603.47.639.3.tab -mtime -1 -type f -exec ls -l {} \;
# find 999999/1603/47/639/3/1603.47.639.3.tab -name

# ls -l --time-style=long-iso find 999999/1603/47/639/3/
# find 999999/1603/47/639/3/ -mmin -60

# echo "changed_recently"
# changed_recently 999999/1603/47/639/3/ 60



set +x
25 changes: 25 additions & 0 deletions 999999999/999999999.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ ROOTDIR="$(pwd)"
# 1603.45.49.tsv, 1603.47.639.3.tsv, 1603.47.15924.tsv,
NUMERORDINATIO_DATUM="${ROOTDIR}/999999/999999"

#######################################
# Return if a path (or a file) don't exist or if did not changed recently.
# Use case: reload functions that depend on action of older ones
#
# Globals:
# None
# Arguments:
# path_or_file
# maximum_time (default: 5 minutes)
# Outputs:
# 1 (if need reload, Void if no reload need)
#######################################
changed_recently() {
path_or_file="$1"
maximum_time="${2:-5}"
if [ -e "$path_or_file" ]; then
changes=$(find "$path_or_file" -mmin -"$maximum_time")
if [ -z "$changes" ]; then
return 0
fi
fi
echo "1"
}


#######################################
# contains(string, substring)
#
Expand Down

0 comments on commit fb5a9e8

Please sign in to comment.