<commit_before># This file is part of NIT ( http://www.nitlanguage.org ).
#
# Copyright 2014 <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Script to scan Github for repositories possibly using JNI.
module github_search_for_jni

import github_api

# The proprieties introduced by this redef are to be used only on HashMap
# representing a Github repository.
#
# REQUIRE `assert self isa HashMap[String, nullable Object]`
# REQUIRE `for v in self.values do assert v isa Int
redef class HashMap[K, V]
	# The repository has at least 50% Java code
	fun has_lots_of_java: Bool
	do
		var java_count = 0
		if keys.has("Java") then java_count = self["Java"].as(Int)

		if java_count == 0 then return false

		var total = 0
		for k, v in self do
			assert k isa String
			assert v isa Int
			total += v
		end

		return java_count * 100 / total > 50
	end

	# The repository has at least 100 lines of C code
	fun has_some_c: Bool
	do
		var c_count = 0
		if keys.has("C") then c_count = self["C"].as(Int)
		return c_count > 100
	end<commit_msg>github_search_for_jni: really execute contracts<commit_after># This file is part of NIT ( http://www.nitlanguage.org ).
#
# Copyright 2014 <NAME> <<EMAIL>>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Script to scan Github for repositories possibly using JNI.
module github_search_for_jni

import github_api

# The proprieties introduced by this redef are to be used only on HashMap
# representing a Github repository.
redef class HashMap[K, V]
	# The repository has at least 50% Java code
	fun has_lots_of_java: Bool
	do
		assert self isa HashMap[String, nullable Object]
		var java_count = 0
		if keys.has("Java") then java_count = self["Java"].as(Int)

		if java_count == 0 then return false

		var total = 0
		for k, v in self do
			assert v isa Int
			total += v
		end

		return java_count * 100 / total > 50
	end

	# The repository has at least 100 lines of C code
	fun has_some_c: Bool
	do
		assert self isa HashMap[String, nullable Object]
		var c_count = 0
		if keys.has("C") then c_count = self["C"].as(Int)
		return c_count > 100
	end
{'fraction_non_alphanumeric': 0.07451612903225806, 'fraction_numerical': 0.016129032258064516, 'mean_word_length': 3.8152173913043477, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7148419', 'n_tokens_mistral': 1020, 'n_tokens_neox': 921, 'n_words': 431}