Package org.opensextant.output
Class GISDataModel
- java.lang.Object
-
- org.opensextant.output.GISDataModel
-
public class GISDataModel extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
field_order
java.util.Set<java.lang.String>
field_set
protected boolean
includeCoordinate
protected boolean
includeOffsets
protected org.slf4j.Logger
log
protected org.opensextant.giscore.events.Schema
schema
protected boolean
useFileHyperlink
-
Constructor Summary
Constructors Constructor Description GISDataModel(java.lang.String jobName, boolean includeOffsets, boolean includeCoordinate)
Instantiates a new GIS data model.GISDataModel(java.lang.String jobName, boolean includeOffsets, boolean includeCoordinate, boolean buildSchema)
Instantiates a new GIS data model.
-
Method Summary
Modifier and Type Method Description protected void
addAdditionalAttributes(org.opensextant.giscore.events.Feature row, java.util.Map<java.lang.String,java.lang.Object> rowAttributes)
If the caller has additional data to attach to records, allow them to add fields to schema at runtime and map their data to keys on GeocodingResult Similarly, you could have Geocoding row-level attributes unique to the geocoding whereas attrs on GeocodingResult are global for all geocodings in that result set.protected void
addColumn(org.opensextant.giscore.events.Feature row, org.opensextant.giscore.events.SimpleField f, double d)
Add a column of data to output; Field is validated.protected void
addColumn(org.opensextant.giscore.events.Feature row, org.opensextant.giscore.events.SimpleField f, int d)
Add a column of data to output; Field is validated.protected void
addColumn(org.opensextant.giscore.events.Feature row, org.opensextant.giscore.events.SimpleField f, java.lang.Object d)
Add a column of data to output; Field is validated ; value is not added if null.protected void
addConfidence(org.opensextant.giscore.events.Feature row, int conf)
Adds the confidence.protected void
addContext(org.opensextant.giscore.events.Feature row, TextMatch g)
Adds the context.void
addField(java.lang.String fld)
Add a field key to the field order; Caller must also be responsible for ensuring field is valid and exists in Schema.protected void
addFilePaths(org.opensextant.giscore.events.Feature row, java.lang.String recordFile, java.lang.String recordTextFile)
Adds the file paths.protected void
addLatLon(org.opensextant.giscore.events.Feature row, Geocoding g)
Adds the lat lon.protected void
addMatchMethod(org.opensextant.giscore.events.Feature row, java.lang.String method)
Allows caller to add a method or pattern id of sorts to denote how match was derived.protected void
addMatchMethod(org.opensextant.giscore.events.Feature row, TextMatch match)
Adds the match method.protected void
addMatchText(org.opensextant.giscore.events.Feature row, TextMatch g)
Adds the match text.protected void
addOffsets(org.opensextant.giscore.events.Feature row, TextMatch m)
Adds the offsets.protected void
addPlaceData(org.opensextant.giscore.events.Feature row, Geocoding g)
Adds the place data.protected void
addPrecision(org.opensextant.giscore.events.Feature row, Geocoding g)
Adds the precision.java.util.List<org.opensextant.giscore.events.Feature>
buildRows(int id, Geocoding g, TextMatch m, java.util.Map<java.lang.String,java.lang.Object> rowAttributes, ExtractionResult res)
Builds a GISCore feature array (rows) from a given array of TextMatches; Enrich the features with record-level attributes (columns).protected org.opensextant.giscore.events.Schema
buildSchema(java.lang.String jobName)
Create a schema instance with the fields properly typed and ordered.protected boolean
canAdd(org.opensextant.giscore.events.SimpleField f)
Can add.protected void
defaultFields()
Default fields.protected java.lang.String
formatConfidence(double conf)
Convenience method for managing how confidence number is reported in output.protected org.opensextant.giscore.events.SimpleField
getField(java.lang.String field)
Gets the field.org.opensextant.giscore.events.Schema
getSchema()
Gets the schema.void
removeField(java.lang.String fld)
Removes the field.
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
includeOffsets
protected boolean includeOffsets
-
includeCoordinate
protected boolean includeCoordinate
-
useFileHyperlink
protected boolean useFileHyperlink
-
schema
protected org.opensextant.giscore.events.Schema schema
-
field_order
protected java.util.List<java.lang.String> field_order
-
field_set
public java.util.Set<java.lang.String> field_set
-
-
Constructor Detail
-
GISDataModel
public GISDataModel(java.lang.String jobName, boolean includeOffsets, boolean includeCoordinate)
Instantiates a new GIS data model.- Parameters:
jobName
- the job nameincludeOffsets
- the include offsetsincludeCoordinate
- the include coordinate
-
GISDataModel
public GISDataModel(java.lang.String jobName, boolean includeOffsets, boolean includeCoordinate, boolean buildSchema)
Instantiates a new GIS data model.- Parameters:
jobName
- the job nameincludeOffsets
- the include offsetsincludeCoordinate
- the include coordinatebuildSchema
- the build schema
-
-
Method Detail
-
addPlaceData
protected void addPlaceData(org.opensextant.giscore.events.Feature row, Geocoding g)
Adds the place data.- Parameters:
row
- row of datag
- geocoding
-
addPrecision
protected void addPrecision(org.opensextant.giscore.events.Feature row, Geocoding g)
Adds the precision.- Parameters:
row
- row of datag
- geocoding
-
addConfidence
protected void addConfidence(org.opensextant.giscore.events.Feature row, int conf)
Adds the confidence.- Parameters:
row
- row of dataconf
- confidence
-
addOffsets
protected void addOffsets(org.opensextant.giscore.events.Feature row, TextMatch m)
Adds the offsets.- Parameters:
row
- datam
- match metadata
-
addLatLon
protected void addLatLon(org.opensextant.giscore.events.Feature row, Geocoding g)
Adds the lat lon. to the given data row.- Parameters:
row
- datag
- geocoding
-
addAdditionalAttributes
protected void addAdditionalAttributes(org.opensextant.giscore.events.Feature row, java.util.Map<java.lang.String,java.lang.Object> rowAttributes) throws ConfigException
If the caller has additional data to attach to records, allow them to add fields to schema at runtime and map their data to keys on GeocodingResult Similarly, you could have Geocoding row-level attributes unique to the geocoding whereas attrs on GeocodingResult are global for all geocodings in that result set.- Parameters:
row
- the rowrowAttributes
- the row attributes- Throws:
ConfigException
- the config exception
-
addFilePaths
protected void addFilePaths(org.opensextant.giscore.events.Feature row, java.lang.String recordFile, java.lang.String recordTextFile)
Adds the file paths.- Parameters:
row
- datarecordFile
- original filerecordTextFile
- text version of original
-
addContext
protected void addContext(org.opensextant.giscore.events.Feature row, TextMatch g)
Adds the context.- Parameters:
row
- the rowg
- the g
-
addMatchText
protected void addMatchText(org.opensextant.giscore.events.Feature row, TextMatch g)
Adds the match text.- Parameters:
row
- the rowg
- the g
-
addMatchMethod
protected void addMatchMethod(org.opensextant.giscore.events.Feature row, java.lang.String method)
Allows caller to add a method or pattern id of sorts to denote how match was derived.- Parameters:
row
- the rowmethod
- the method
-
addMatchMethod
protected void addMatchMethod(org.opensextant.giscore.events.Feature row, TextMatch match)
Adds the match method.- Parameters:
row
- the rowmatch
- the match
-
buildRows
public java.util.List<org.opensextant.giscore.events.Feature> buildRows(int id, Geocoding g, TextMatch m, java.util.Map<java.lang.String,java.lang.Object> rowAttributes, ExtractionResult res) throws ConfigException
Builds a GISCore feature array (rows) from a given array of TextMatches; Enrich the features with record-level attributes (columns). If provided result has .input set, then conext and other metadata for this match will be pulled from it. Context is not pulled at match time, as it is not used by most processing -- it tends to be more of an output/formatting issue. And only matches that pass any filters are enriched with context and other metadaa.- Parameters:
id
- the idg
- the gm
- the mrowAttributes
- the row attributesres
- the res- Returns:
- the list
- Throws:
ConfigException
- schema configuration error
-
formatConfidence
protected java.lang.String formatConfidence(double conf)
Convenience method for managing how confidence number is reported in output.- Parameters:
conf
- the conf- Returns:
- the string
-
getSchema
public org.opensextant.giscore.events.Schema getSchema()
Gets the schema.- Returns:
- the schema
-
buildSchema
protected org.opensextant.giscore.events.Schema buildSchema(java.lang.String jobName) throws ConfigException
Create a schema instance with the fields properly typed and ordered.- Parameters:
jobName
- the job name- Returns:
- the schema
- Throws:
ConfigException
- schema configuration error
-
getField
protected org.opensextant.giscore.events.SimpleField getField(java.lang.String field) throws ConfigException
Gets the field.- Parameters:
field
- the field- Returns:
- the field
- Throws:
ConfigException
- the config exception
-
canAdd
protected boolean canAdd(org.opensextant.giscore.events.SimpleField f)
Can add.- Parameters:
f
- the f- Returns:
- true, if successful
-
addColumn
protected void addColumn(org.opensextant.giscore.events.Feature row, org.opensextant.giscore.events.SimpleField f, java.lang.Object d)
Add a column of data to output; Field is validated ; value is not added if null.- Parameters:
row
- the rowf
- the fd
- the d
-
addColumn
protected void addColumn(org.opensextant.giscore.events.Feature row, org.opensextant.giscore.events.SimpleField f, int d)
Add a column of data to output; Field is validated.- Parameters:
row
- the rowf
- the fd
- the d
-
addColumn
protected void addColumn(org.opensextant.giscore.events.Feature row, org.opensextant.giscore.events.SimpleField f, double d)
Add a column of data to output; Field is validated.- Parameters:
row
- the rowf
- the field named
- value
-
addField
public void addField(java.lang.String fld) throws ConfigException
Add a field key to the field order; Caller must also be responsible for ensuring field is valid and exists in Schema.- Parameters:
fld
- field name- Throws:
ConfigException
- the config exception
-
removeField
public void removeField(java.lang.String fld) throws ConfigException
Removes the field.- Parameters:
fld
- field name- Throws:
ConfigException
- the config exception
-
defaultFields
protected final void defaultFields()
Default fields.
-
-