<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def append(self, val):
 """Connect any new results to the resultset. This is where all the heavy lifting is done for creating results: - We add a datatype here, so that each result can handle validation etc independently. This is so that scraper authors don't need to worry about creating and passing around datatype objects. - As the scraper author yields result objects, we append them to a resultset. - This is also where we normalize dialects. """

        val.resultset = self
        val.dataset = self.dataset

        # Check result dimensions against available dimensions for this dataset
        if val.dataset:
            dataset_dimensions = self.dataset.dimensions
            for k, v in val.raw_dimensions.items():
                if k not in dataset_dimensions:
                    d = Dimension(k)
                else:
                    d = dataset_dimensions[k]

                # Normalize if we have a datatype and a foreign dialect
                normalized_value = unicode(v)
                if d.dialect and d.datatype:
                    if d.dialect in d.datatype.dialects:
                        for av in d.allowed_values:
                            # Not all allowed_value have all dialects
                            if unicode(v) in av.dialects.get(d.dialect, []):
                                normalized_value = av.value
                                # Use first match
                                # We do not support multiple matches
                                # This is by design.
                                break

                # Create DimensionValue object
                if isinstance(v, DimensionValue):
                    dim = v
                    v.value = normalized_value
                else:
                    if k in dataset_dimensions:
                        dim = DimensionValue(normalized_value, d)
                    else:
                        dim = DimensionValue(normalized_value, Dimension())

                val.dimensionvalues.append(dim)

            # Add last list of dimension values to the ResultSet
            # They will usually be the same for each result
            self.dimensionvalues = val.dimensionvalues

        super(ResultSet, self).append(val)