<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resource_type(self, resource_id):
 """ Given an ID, determines whether a given resource is a resource or a resource_component. :param resource_id string: The URI of the resource whose type to determine. :raises ArchivesSpaceError: if the resource_id does not appear to be either type. """

        match = re.search(
            r"repositories/\d+/(resources|archival_objects)/\d+", resource_id
        )
        if match and match.groups():
            type_ = match.groups()[0]
            return "resource" if type_ == "resources" else "resource_component"
        else:
            raise ArchivesSpaceError(
                "Unable to determine type of provided ID: {}".format(resource_id)
            )