Skip to content

589-fixRunnerExamples #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
default basedir = FLUX_DIR;

basedir|
read-dir|
filter-strings(".*\\.beacon", passmatches="true")|
open-file|
read-beacon(metadatafilter="name|isil")|
stream-to-triples|
sort-triples(by="subject")|
collect-triples|
encode-formeta(style="multiline")|
write("stdout");
basedir
| read-dir
| filter-strings(".*\\.beacon", passmatches="true")
| open-file
| read-beacon(metadatafilter="name|isil")
| stream-to-triples
| sort-triples(by="subject")
| collect-triples
| encode-formeta(style="multiline")
| write("stdout");
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default fileName = FLUX_DIR + "austriaforum.beacon";

fileName|
open-file(encoding="UTF-8")|
read-beacon(metadatafilter="name|isil")|
encode-formeta(style="multiline")|
write("stdout");
fileName
| open-file(encoding="UTF-8")
| read-beacon(metadatafilter="name|isil")
| encode-formeta(style="multiline")
| write("stdout");
38 changes: 19 additions & 19 deletions metafacture-runner/src/main/dist/examples/beacon/create/create.flux
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ header|open-file|as-lines|@Y;
//count references
"counting references in " + dump | write("stdout");

dump|
open-file|
as-lines|
catch-object-exception|
decode-pica|
batch-log(batchsize="100000")|
morph(FLUX_DIR + "extract.xml", *)|
stream-to-triples(redirect="true")|
sort-triples(by="subject")|
collect-triples|
morph(FLUX_DIR + "output.xml")|
batch-log("merged ${totalRecords}", batchsize="100000")|
stream-to-triples|
template("${s}")|
@Y;

@Y|
wait-for-inputs("2")|
write(out);
dump
| open-file
| as-lines
| catch-object-exception
| decode-pica
| batch-log(batchsize="100000")
| fix(FLUX_DIR + "extract.fix", *)
| stream-to-triples(redirect="true")
| sort-triples(by="subject")
| collect-triples
| fix(FLUX_DIR + "output.fix")
| batch-log("merged ${totalRecords}", batchsize="100000")
| stream-to-triples
| template("${s}")
| @Y;

@Y
| wait-for-inputs("2")
| write(out);



Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 002@ not repeatable

if any_match("002@.0", "^Tp.*$")
copy_field("002@.0","ok")
end

# <!-- DBSM: -->
# <!-- (006U $0 “04p01*”) or (017A $a “yy”) -->
if any_match("006U.0","04p01.*")
add_field("@value","DBSM|ALL")
elsif any_equal("017A.a","yy")
add_field("@value","DBSM|ALL")

# <!-- DEA: -->
# <!-- (001@ $a 2””) or (209A $f “Exilarchiv” or 209A $f “HB/EB”) -->
elsif any_equal("001@.a","2")
add_field("@value","DEA|ALL")
elsif any_equal("209A.f","HB/EB")
add_field("@value","DEA|ALL")

# <!-- DMA: -->
# <!-- (002@ $0 “G*” or 002@ $0 “M*”) or (006U $0 “10,P01*”) -->

elsif any_equal("002@.0","^[GM].*")
add_field("@value","DMA|ALL")

elsif any_equal("006U.0","^10,P01.*")
add_field("@value","DMA|ALL")
else
add_field("@value","ALL")
end

# Test if type variable fits

if any_contain("@value","$[type]")
add_field("@value","$[type]")
else
remove_field("@value")
end

do list(path: "041A*|028A*|029B*|028C*|028Q*|028P*|028F*|028M*|028D*|028E*", "var":"$i")
trim("$i.9")
to_var("$i.9","ref")
if exists("$i.9")
copy_field("@value","{to:$[ref]}refed")
end
end

retain("{to*","ok")

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
unless exists("refed")
remove_field("ok","")
end

unless exists("ok")
remove_field("ok","")
end

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
default fileName = FLUX_DIR + "gnd-sample.pica";

fileName|
open-file|
as-lines|
decode-pica|
morph(FLUX_DIR + "gnd-type.xml")|
stream-to-triples|
count-triples(countBy="object")|
template("${s}\t${o}")|
write("stdout");
fileName
| open-file
| as-lines
| decode-pica
| fix(FLUX_DIR + "gnd-type.fix")
| stream-to-triples
| count-triples(countBy="object")
| template("${s}\t${o}")
| write("stdout");
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if any_match("002@.0","...*")
replace_all("002@.0","^(..).*","$1") #only keep the first two letters
retain("002@.0") # only keep the relevent element
else
reject()
end
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

catalogue|
open-file|
as-lines|
catch-object-exception|
decode-pica|
batch-log(batchsize="100000")|
morph(FLUX_DIR + "subject-cooccurrence.xml")|
stream-to-triples|
count-triples(countBy="object")|
calculate-metrics("X2")|
template("${s} ${o}")|
//write("stdout");
catalogue
| open-file
| as-lines
| catch-object-exception
| decode-pica
| batch-log(batchsize="100000")
| morph(FLUX_DIR + "subject-cooccurrence.xml")
| stream-to-triples
| count-triples(countBy="object")
| calculate-metrics("X2")
| template("${s} ${o}")
| //write("stdout");
write(FLUX_DIR+"x2.dat");
11 changes: 11 additions & 0 deletions metafacture-runner/src/main/dist/examples/count/subjects/10.pica

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
040118908:count=1 (STRING)
040221539:count=1 (STRING)
040356337:count=1 (STRING)
040511766:count=1 (STRING)
040600874:count=1 (STRING)
040667243:count=1 (STRING)
040674886:count=1 (STRING)
042194814:count=2 (STRING)
942342860:count=1 (STRING)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
do list(path:"041A*|041A","var":"$i") # Until https://github.com/metafacture/metafacture-core/issues/651 is fixed one hass to add "041A"
copy_field("$i.9","relevantField.$append")
end

trim("relevantField.*")
uniq("relevantField")

retain("relevantField")
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

default counts="myflux/counts.dat";
default counts=FLUX_DIR + "counts.dat";
default catalogue = FLUX_DIR + "10.pica";

//count references
"counting references in " + catalogue | write("stdout");

catalogue|
open-file|
as-lines|
catch-object-exception|
decode-pica|
morph(FLUX_DIR + "references.xml")|
stream-to-triples|
count-triples(countBy="object")|

write("subjects.dat");
catalogue
| open-file
| as-lines
| catch-object-exception
| decode-pica
| fix(FLUX_DIR + "references.fix")
| stream-to-triples
| count-triples(countBy="object")
| write(counts);


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if any_match("002@.0","^Tp.*")
if any_match("041R.a",".*[Aa][Rr][Zz][Tt].*")
nothing()
else
reject()
end
else
reject()
end
11 changes: 11 additions & 0 deletions metafacture-runner/src/main/dist/examples/filter/fix/filter.flux
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// opens file 'fileName', interprets the content as pica and filters the results

default fileName = FLUX_DIR + "gnd-sample.pica";

fileName
| open-file
| as-lines
| decode-pica
| fix(FLUX_DIR + "filter.fix") // Fix does not use the filter function but has its own filter mechanism within fix.
| encode-formeta(style="verbose")
| write("stdout");
Loading