422cb49b31
- Create Dockerfile and entrypoint script for application setup - Implement pattern loading from Excel and weight caching - Develop core functions for Hopfield and Hamming networks - Add Sinatra web server for user interaction - Create HTML interface for displaying patterns and results - Include necessary gems in Gemfile and lockfile - Add .dockerignore and .gitignore files
59 lines
1.4 KiB
Ruby
59 lines
1.4 KiB
Ruby
require 'rubyXL'
|
|
require 'rubyXL/convenience_methods'
|
|
|
|
PATTERNS = {
|
|
'T' => [
|
|
[ 1, 1, 1, 1, 1, 1, 1, 1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1]
|
|
],
|
|
'H' => [
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1],
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1],
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1],
|
|
[ 1, 1, 1, 1, 1, 1, 1, 1],
|
|
[ 1, 1, 1, 1, 1, 1, 1, 1],
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1],
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1],
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1]
|
|
],
|
|
'E' => [
|
|
[ 1, 1, 1, 1, 1, 1, 1, 1],
|
|
[ 1,-1,-1,-1,-1,-1,-1,-1],
|
|
[ 1,-1,-1,-1,-1,-1,-1,-1],
|
|
[ 1, 1, 1, 1, 1, 1,-1,-1],
|
|
[ 1, 1, 1, 1, 1, 1,-1,-1],
|
|
[ 1,-1,-1,-1,-1,-1,-1,-1],
|
|
[ 1,-1,-1,-1,-1,-1,-1,-1],
|
|
[ 1, 1, 1, 1, 1, 1, 1, 1]
|
|
],
|
|
'X' => [
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1],
|
|
[-1, 1,-1,-1,-1,-1, 1,-1],
|
|
[-1,-1, 1,-1,-1, 1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1,-1, 1, 1,-1,-1,-1],
|
|
[-1,-1, 1,-1,-1, 1,-1,-1],
|
|
[-1, 1,-1,-1,-1,-1, 1,-1],
|
|
[ 1,-1,-1,-1,-1,-1,-1, 1]
|
|
]
|
|
}
|
|
|
|
wb = RubyXL::Workbook.new
|
|
wb.worksheets.delete_at(0)
|
|
PATTERNS.each do |name, matrix|
|
|
sheet = wb.add_worksheet(name)
|
|
matrix.each_with_index do |row, r|
|
|
row.each_with_index do |val, c|
|
|
sheet.add_cell(r, c, val == 1 ? 'x' : nil)
|
|
end
|
|
end
|
|
end
|
|
wb.write('patterns.xlsx')
|
|
puts "Создан patterns.xlsx (листы: #{PATTERNS.keys.join(', ')})"
|