<commit_before>
# The model service will wrap a singleton Model class which manages a reference to a root
# Context entity. This separates users of the model service one level from JEFRi- they
# still get all the entities, but can't do runtime things directly.

model = (JEFRi) ->
	class Model
		->
			@reset!
			@load
			@runtime = JEFRi

		reset: !->
			<~! JEFRi.ready.then
			@context = JEFRi.build \Context
			@ready <: {}

		load: !->
			load = !~>
				@ready -:> load
				hostsEntity = JEFRi.build \Entity,
					"name": "Host"
					"key": "host_id"
				@context.entities hostsEntity

				properties = [
					JEFRi.build "Property",
						name: "host_id",
						type: "string"
					JEFRi.build "Property",
						name: "hostname",
						type: "string"
					JEFRi.build "Property",
						name: "ip",
						type: "string"
					JEFRi.build "Property",
						name: "mac",
						type: "string"
				]
				hostsEntity.properties properties

			@ready :> load

		addEntity: !->
			@context.entities JEFRi.build \Entity


	new Model!

angular.module \modeler
	.factory \Model, [\JEFRi, model]
	.run [\Model, -> it.load!]<commit_msg>Added more robust model examples.<commit_after>
# The model service will wrap a singleton Model class which manages a reference to a root
# Context entity. This separates users of the model service one level from JEFRi- they
# still get all the entities, but can't do runtime things directly.

model = (JEFRi) ->
	class Model
		->
			@reset!
			@load
			@runtime = JEFRi

		reset: !->
			<~! JEFRi.ready.then
			@context = JEFRi.build \Context
			@ready <: {}

		load: !->
			load = !~>
				@ready -:> load

				router = JEFRi.build \Entity,
					"name": "Router",
					"key": "router_id"

				host = JEFRi.build \Entity,
					"name": "Host"
					"key": "host_id"

				router.properties [
					JEFRi.build \Property,
						name: \router_id
						type: \string
					JEFRi.build \Property,
						name: \name
						type: \string
				]

				router-hosts = JEFRi.build \Relationship,
					name: \hosts
					type: \has_many
					to_property: \router_id
					from_property: \router_id
				router-hosts.to host
				router-hosts.from router

				host.properties [
					JEFRi.build "Property",
						name: "host_id",
						type: "string"
					JEFRi.build "Property",
						name: "hostname",
						type: "string"
					JEFRi.build "Property",
						name: "ip",
						type: "string"
					JEFRi.build "Property",
						name: "mac",
						type: "string"
					JEFRi.build \Property,
						name: \router_id
						type: \string
				]

				hostRouter = JEFRi.build \Relationship,
					name: \router
					type: \has_a
					to_property: \router_id
					from_property: \router_id
				host-router.to router
				host-router.from host

				@context.entities [host, router]

			@ready :> load

		addEntity: !->
			@context.entities JEFRi.build \Entity


	new Model!

angular.module \modeler
	.factory \Model, [\JEFRi, model]
	.run [\Model, -> it.load!]
{'fraction_non_alphanumeric': 0.12491536899119837, 'fraction_numerical': 0.0, 'mean_word_length': 2.3732876712328768, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7313458', 'n_tokens_mistral': 1362, 'n_tokens_neox': 989, 'n_words': 284}