<commit_before>require 'json'

class OntologySearch

  def initialize()
  end

  def makeKeywordListJson(prefix)
    keywordList = makeKeywordList(prefix)
    return JSON.generate(keywordList)
  end

  def makeKeywordList(prefix)
    textList = Set.new
    textList.add(prefix) unless Ontology.where("name = :prefix", prefix: prefix).length == 0
    textList.add(prefix) unless Entity.where("name = :prefix", prefix: prefix).length == 0
    Ontology.where("name LIKE :prefix", prefix: "#{prefix}%").each do |ontology|
      textList.add(ontology.name)
    end
    Entity.where("name LIKE :prefix", prefix: "#{prefix}%").each do |symbol|
      textList.add(symbol.name)
    end
    textList = textList.to_a();
    textList = textList.sort
    keywordListFactory = KeywordListFactory.new()
    textList.each do |text|
      keywordListFactory.addKeyword(text)
    end
    keywordList = keywordListFactory.getKeywordList()
    return keywordList
  end

  def makeSmallBeanList()

  end

end<commit_msg>Limit suggestions to 100 keywords (exact match and newly updated first)<commit_after>require 'json'

class OntologySearch

  def initialize()
  end

  def makeKeywordListJson(prefix)
    keywordList = makeKeywordList(prefix)
    return JSON.generate(keywordList)
  end

  def makeKeywordList(prefix)
    textList = Set.new
    textList.add(prefix) unless Ontology.where("name = :prefix", prefix: prefix).length == 0
    textList.add(prefix) unless Entity.where("name = :prefix", prefix: prefix).length == 0
    Ontology.where("name LIKE :prefix", prefix: "#{prefix}%").order("updated_at desc").limit(50).each do |ontology|
      textList.add(ontology.name)
    end
    Entity.where("name LIKE :prefix", prefix: "#{prefix}%").order("updated_at desc").limit(50).each do |symbol|
      textList.add(symbol.name)
    end
    textList = textList.to_a();
    textList = textList.sort
    keywordListFactory = KeywordListFactory.new()
    textList.each do |text|
      keywordListFactory.addKeyword(text)
    end
    keywordList = keywordListFactory.getKeywordList()
    return keywordList
  end

  def makeSmallBeanList()

  end

end
{'fraction_non_alphanumeric': 0.11571025399811853, 'fraction_numerical': 0.0051740357478833494, 'mean_word_length': 3.958041958041958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '79184', 'n_tokens_mistral': 663, 'n_tokens_neox': 645, 'n_words': 151}