Mercurial > hg > cc > cirrus_home
annotate bin/reExtract.sh @ 39:822cfbf134d3
towards re-running extraction in part
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 02 Apr 2020 19:14:23 +0100 |
parents | |
children | 0d1f6c971d5e |
rev | line source |
---|---|
39
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 #!/usr/bin/bash |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
2 # Usage: reExtract.sh 20..-.. < files... |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
3 # Input is list of paths to relative path of warc files |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
4 # under /beegfs/common_crawl/CC-MAIN-$1 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 function edex () { |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 echo "$1" | \ |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 cut -f 5 -d - | cut -f 1 -d .|sed 's/^00//' | \ |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
9 echo $(($(fgrep -n -f - ~/by11n.txt | cut -f 1 -d :) - 1)) |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
10 } |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
12 h=/beegfs/common_crawl/CC-MAIN-$1 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
13 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
14 mkdir -p /dev/shm/rex |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
15 cd /dev/shm/rex |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
16 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
17 sed 's/\// /;s/-00/ /;s/.warc.gz//' | \ |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
18 while read s p i |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
19 do |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
20 printf "%s\t%s\t%s\t%s\n" $(edex $i) $s $p $i |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
21 done > in.txt |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
22 for s in $(cut -f 2 in.txt| sort -u) |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
23 do |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
24 mkdir -p $s |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
25 cd $s |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
26 for e in $(egrep "\b$p\b" in.txt |cut -f 1 | sort -u) |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
27 do |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
28 tar -xf $h/$s/extract_$e.tar |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
29 |
822cfbf134d3
towards re-running extraction in part
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
30 |