Skip to content

Commit 29d1360

Browse files
committed
Fix order; rename variable; remove empty line (metafacture-core#415)
1 parent 62da8a0 commit 29d1360

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ The separator (`sep_char`) will vary depending on the source file, e.g.:
190190
| CSV | `,` or `;` |
191191
| TSV | `\t` |
192192

193+
<<<<<<< HEAD
193194
Options:
194195

195196
- `allow_empty_values`: Sets whether to allow empty values in the filemap or to ignore these entries. (Default: `false`)
@@ -223,6 +224,17 @@ put_map("<mapName>",
223224
)
224225
```
225226

227+
##### `put_rdfmap`
228+
229+
Defines an external RDF map for lookup from a file or an HTTP(S) resource.
230+
As the RDF map is reducing RDF triples to a key/value map it is mandatory to set the target.
231+
The targeted RDF property can optionally be bound by an RDF language tag.
232+
233+
```perl
234+
put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>")
235+
put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>, target_language: "<rdfLanguageTag>")
236+
```
237+
226238
##### `put_var`
227239
228240
Defines a single global variable that can be referenced with `$[<variableName>]`.
@@ -620,7 +632,7 @@ lookup("path.to.field", "map-name", print_unknown: "true", destination: "unknown
620632
##### `lookup_rdf`
621633
622634
Looks up matching values in an RDF resource and replaces the field value with a match defined by a targeted RDF property. External files or HTTP(S) resources as well as internal RDF maps can be used.
623-
The targeted RDF property can optional be bound by an RDF language tag.
635+
The targeted RDF property can optionalyl be bound by an RDF language tag.
624636
625637
```perl
626638
lookup_rdf("<sourceField>", "<rdfFile>", target: "<rdfProperty>")

metafix/src/main/java/org/metafacture/metafix/FixMethod.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,5 +674,4 @@ public void apply(final Metafix metafix, final Record record, final List<String>
674674

675675
private static final Random RANDOM = new Random();
676676

677-
678677
}

metafix/src/main/java/org/metafacture/metafix/api/FixFunction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,24 @@ default Stream<Value> flatten(final Stream<Value> stream) {
111111
));
112112
}
113113

114-
default void lookup(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options, final FixFunction kindOfMap) {
115-
final Map<String, String> map = getMap(metafix, record, params, options, kindOfMap);
114+
default void lookup(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options, final FixFunction mapFunction) {
115+
final Map<String, String> map = getMap(metafix, record, params, options, mapFunction);
116116
record.transform(params.get(0), oldValue -> {
117117
final String newValue = map.getOrDefault(oldValue, map.get(Maps.DEFAULT_MAP_KEY));
118118
return newValue != null ? newValue : getBoolean(options, "delete") ? null : oldValue;
119119
});
120120
}
121121

122-
static Map<String, String> getMap(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options, final FixFunction kindOfMap) {
122+
static Map<String, String> getMap(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options, final FixFunction mapFunction) {
123123
final Map<String, String> map;
124124
if (params.size() <= 1) {
125125
map = options;
126126
}
127127
else {
128-
final String mapName = kindOfMap.toString().equals("put_rdfmap") ? (params.size() > 1 ? params.get(1) : params.get(0)) + options.get(RdfMap.TARGET) + options.getOrDefault(RdfMap.TARGET_LANGUAGE, "") : params.get(1);
128+
final String mapName = mapFunction.toString().equals("put_rdfmap") ? (params.size() > 1 ? params.get(1) : params.get(0)) + options.get(RdfMap.TARGET) + options.getOrDefault(RdfMap.TARGET_LANGUAGE, "") : params.get(1);
129129
if (!metafix.getMapNames().contains(mapName)) {
130130
if (mapName.contains(".") || mapName.contains(File.separator)) {
131-
kindOfMap.apply(metafix, record, Arrays.asList(mapName), options);
131+
mapFunction.apply(metafix, record, Arrays.asList(mapName), options);
132132
}
133133
else {
134134
// Probably an unknown internal map? Log a warning?

0 commit comments

Comments
 (0)