Giter Club home page Giter Club logo

ruby-euclidean-text's Introduction

Example Euclidean histogram

histo1 = TextTools.read_to_histogram(‘aol1.txt’)
histo2 = TextTools.read_to_histogram(‘aol2.txt’)
histo3 = TextTools.read_to_histogram(‘other1.txt’)
histo4 = TextTools.read_to_histogram(‘aol3.txt’)
histo5 = TextTools.read_to_histogram(‘cell1.txt’)
histo6 = TextTools.read_to_histogram(‘aol4.txt’)
histo7 = TextTools.read_to_histogram(‘aol5.txt’)
histo8 = TextTools.read_to_histogram(‘ritchie1.txt’)
histo9 = TextTools.read_to_histogram(‘ritchie2.txt’)

#Pretend that we’re working with a graph

#Vertex set
vertex = []
vertex << histo1
vertex << histo2
vertex << histo3
vertex << histo4
vertex << histo5
vertex << histo6
vertex << histo7
vertex << histo8
vertex << histo9

edges=[]
rejected=[]

vertex.each_index do |x|
i = 1
until vertex[x+i].nil?
distance = TextTools.histogram_distance(vertex[x], vertex[x+i])
if distance < 400.0
edges << [x,x+i, distance]
# puts “*
# puts “Same topic!”
# puts x+1
# puts x + i+1
# puts distance
# puts “*
else
rejected << [x,x+i, distance]
# puts “**”
# puts “Too far!”
# puts x+1
# puts x + i+1
# puts distance
# puts “**”
end
i += 1
end

end

puts “Related Histograms”
edges.each do |x|
puts “#{x0 + 1} #{x1 + 1} Distance #{x2}”
end

puts “\nUnrelated Histograms”
rejected.each do |x|
puts “#{x0 + 1} #{x1 + 1} Distance #{x2}”
end

ruby-euclidean-text's People

Contributors

cchandler avatar

Stargazers

Angus H. avatar Adolfo De Unánue avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.