Property and PropertyType
followthemoney.property.Property
A definition of a value-holding field on a schema. Properties define the field type and other possible constraints. They also serve as entity to entity references.
description
property
A longer description of the semantics of this property.
label
property
User-facing title for this property.
caption(value)
Return a user-friendly caption for the given value.
generate(model)
Setup method used when loading the model in order to build out the reverse links of the property.
specificity(value)
Return a measure of how precise the given value is.
to_dict()
Return property metadata in a serializable form.
validate(data)
Validate that the data should be stored.
Since the types system doesn't really have validation, this currently tries to normalize the value to see if it passes strict parsing.
followthemoney.types.common.PropertyType
Bases: object
Base class for all property types.
group = None
class-attribute
instance-attribute
Groups are used to invert all the properties of an entity that have a
given type into a single list before indexing them. This way, in Aleph,
you can query for countries:gb
instead of having to make a set of filters
like properties.jurisdiction:gb OR properties.country:gb OR ...
.
label = 'Any'
class-attribute
instance-attribute
A name for this type to be shown to users.
matchable = True
class-attribute
instance-attribute
Matchable types allow properties to be compared with each other in order to assess entity similarity. While it makes sense to compare names, countries or phone numbers, the same isn't true for raw JSON blobs or descriptive text snippets.
max_length = 250
class-attribute
instance-attribute
The maximum length of a single value of this type. This is used to warn when adding individual values that may be malformed or too long to be stored in downstream databases with fixed column lengths. The unit is unicode codepoints (not bytes), the output of Python len().
name = 'any'
class-attribute
instance-attribute
A machine-facing, variable safe name for the given type.
pivot = False
class-attribute
instance-attribute
Pivot property types are like a stronger form of :attr:~matchable
types:
they will be used when value-based lookups are used to find commonalities
between entities. For example, pivot typed-properties are used to show all the
other entities that mention the same phone number, email address or name as the
one currently seen by the user.
plural = 'Any'
class-attribute
instance-attribute
A plural name for this type which can be used in appropriate places in a user interface.
total_size = None
class-attribute
instance-attribute
Some types have overall size limitations in place in order to avoid generating entities that are very large (upstream ElasticSearch has a 100MB document limit). Once the total size of all properties of this type has exceed the given limit, an entity will refuse to add further values.
caption(value, format=None)
Return a label for the given property value. This is often the same as the value, but for types like countries or languages, it would return the label, while other values like phone numbers can be formatted to be nicer to read.
clean(raw, fuzzy=False, format=None, proxy=None)
Create a clean version of a value of the type, suitable for storage in an entity proxy.
clean_text(text, fuzzy=False, format=None, proxy=None)
Specific types can apply their own cleaning routines here (this is called
by clean
after the value has been converted to a string and null values
have been filtered).
compare(left, right)
Comparisons are a float between 0 and 1. They can assume that the given data is cleaned, but not normalised.
compare_safe(left, right)
Compare, but support None values on either side of the comparison.
compare_sets(left, right, func=max)
Compare two sets of values and select the highest-scored result.
country_hint(value)
Determine if the given value allows us to infer a country that it may be related to (e.g. using a country prefix on a phone number or IBAN).
join(values)
Helper function for converting multi-valued FtM data into formats that allow only a single value per field (e.g. CSV). This is not fully reversible and should be used as a last option.
node_id(value)
Return an ID suitable to identify this entity as a typed node in a graph representation of some FtM data. It's usually the same as the the RDF form.
node_id_safe(value)
Wrapper for node_id to handle None values.
pick(values)
Pick the best value to show to the user.
specificity(value)
Return a score for how specific the given value is. This can be used as a weighting factor in entity comparisons in order to rate matching property values by how specific they are. For example: a longer address is considered to be more specific than a short one, a full date more specific than just a year number, etc.
to_dict()
Return a serialisable description of this data type.
validate(value, fuzzy=False, format=None)
Returns a boolean to indicate if the given value is a valid instance of the type.