Royce  Reinger

Royce Reinger

1658857500

Graph-rank: Ruby Implementation Of The PageRank & TextRank Algorithms

About

This gem implements a PageRank class and a class that allows to perform keyword ranking using the TextRank algorithm. Both were ported from the PHP Implementation by @crodas.

Install

gem install graph-rank

Usage

TextRank

Reference: R. Mihalcea and P. Tarau, “TextRank: Bringing Order into Texts,” in Proceedings of EMNLP 2004. Association for Computational Linguistics, 2004, pp. 404–411.

text = 'PageRank is a link analysis algorithm, named after Larry ' +
'Page and used by the Google Internet search engine, that assigns ' +
'a numerical weighting to each element of a hyperlinked set of ' +
'documents, such as the World Wide Web, with the purpose of "measuring"' +
'its relative importance within the set.'

tr = GraphRank::Keywords.new

tr.run(text).inspect

Optionally, you can pass the n-gram size (default = 3), as well as the damping and convergence (see PageRank) to the constructor. Finally, you can set stop words as follows:

tr.stop_words = ["word", "another", "etc"]

PageRank

Reference: Brin, S.; Page, L. (1998). "The anatomy of a large-scale hypertextual Web search engine". Computer Networks and ISDN Systems 30: 107–117.


pr = GraphRank::PageRank.new

pr.add(1,2)
pr.add(1,4)
pr.add(1,5)
pr.add(4,5)
pr.add(4,1)
pr.add(4,3)
pr.add(1,3)
pr.add(3,1)
pr.add(5,1)

puts pr.calculate.inspect

# => [[1, 5.99497754810465], [3, 2.694723988738302], 
#    [5, 2.694723988738302], [4, 2.100731029131304],
#    [2, 2.100731029131304]]

Optionally, you can pass the damping factor (default = 0.85) and the convergence criterion (default = 0.01) as parameters to the PageRank constructor. Additionally, you can pass in an edge weight parameter to #add and it will be used in the PageRank calculation.

Author: louismullie
Source Code: https://github.com/louismullie/graph-rank 
License: View license

#ruby #graph #text

What is GEEK

Buddha Community

Graph-rank: Ruby Implementation Of The PageRank & TextRank Algorithms
Royce  Reinger

Royce Reinger

1658857500

Graph-rank: Ruby Implementation Of The PageRank & TextRank Algorithms

About

This gem implements a PageRank class and a class that allows to perform keyword ranking using the TextRank algorithm. Both were ported from the PHP Implementation by @crodas.

Install

gem install graph-rank

Usage

TextRank

Reference: R. Mihalcea and P. Tarau, “TextRank: Bringing Order into Texts,” in Proceedings of EMNLP 2004. Association for Computational Linguistics, 2004, pp. 404–411.

text = 'PageRank is a link analysis algorithm, named after Larry ' +
'Page and used by the Google Internet search engine, that assigns ' +
'a numerical weighting to each element of a hyperlinked set of ' +
'documents, such as the World Wide Web, with the purpose of "measuring"' +
'its relative importance within the set.'

tr = GraphRank::Keywords.new

tr.run(text).inspect

Optionally, you can pass the n-gram size (default = 3), as well as the damping and convergence (see PageRank) to the constructor. Finally, you can set stop words as follows:

tr.stop_words = ["word", "another", "etc"]

PageRank

Reference: Brin, S.; Page, L. (1998). "The anatomy of a large-scale hypertextual Web search engine". Computer Networks and ISDN Systems 30: 107–117.


pr = GraphRank::PageRank.new

pr.add(1,2)
pr.add(1,4)
pr.add(1,5)
pr.add(4,5)
pr.add(4,1)
pr.add(4,3)
pr.add(1,3)
pr.add(3,1)
pr.add(5,1)

puts pr.calculate.inspect

# => [[1, 5.99497754810465], [3, 2.694723988738302], 
#    [5, 2.694723988738302], [4, 2.100731029131304],
#    [2, 2.100731029131304]]

Optionally, you can pass the damping factor (default = 0.85) and the convergence criterion (default = 0.01) as parameters to the PageRank constructor. Additionally, you can pass in an edge weight parameter to #add and it will be used in the PageRank calculation.

Author: louismullie
Source Code: https://github.com/louismullie/graph-rank 
License: View license

#ruby #graph #text

Angela  Dickens

Angela Dickens

1596485520

Algorithms: Calculating Combination with Ruby

Background

When I learned to code, I hadn’t slept in a math classroom in 14 years.

I studied philosophy and taught courses on Symbolic Logic. I can talk about deductive proofs for days, but when people pull out a of n’s… x²…_ [insert Greek letter] — _I nod along, but trust me, I have no idea what’s happening.

For this reason, I got a huge boost of empowerment when I figured out an algorithm question asking, “How can you determine the mathematical combination (nCr) of two numbers?”

If you’re like ‘what the…?’, then hell yeah, you are me a day ago. Let’s go!

The Meat

Defining the Problem

I’ll try my best to explain a combination:

Image for post

Imagine you’re losing a high stakes poker game. You have sweat on your neck as a couple Mafia grunts stare daggers at you. As the big one cracks his knuckles, you think “It’s a shame I never learned to count cards. But maybe start now?”

Your mind is racing. You start thinking, how do I start? How many possible hands are there in the deck? Well, there are 52 cards. You get 5 distinct cards in each hand, and they can come in any order. Let’s see, some quick math in your head and…

Image for post

Yeah, the answer is not obvious. But, you’re attempting a combination. A combination is when you have a collection of items and you want to find all the possible selections from that collection — for example, every possible hand from a deck of cards.

By the way, the answer is 2,598,960. Each hand has a 1/2,598,960th chance of being drawn. With numbers that big, it’s good we can train a computer to solve the problem.

#ruby #combination #ruby-on-rails #algorithms #dev #algorithms

Noah  Rowe

Noah Rowe

1597226880

The Algorithm for Ranking the Segments of the River Network

The topic of this article is the application of information technologies in environmental science, namely, in hydrology. Below is a description of the algorithm for ranking rivers and the plugin we implemented for the open-source geographic information system QGIS.

An important aspect of hydrological surveys is not only the collection of information received from research expeditions and automatic devices but also the analysis of all the obtained data, including the use of GIS (geoinformation systems). However, exploration of the spatial structure of hydrological systems can be difficult due to a large amount of data. In such cases, we cannot do research without using additional tools that allow us to automate the process.

Visualization plays an important role when working with spatial data. Correct visual representation of the results of the analysis helps to better understand the structure of spatial objects and to know something new. For the image of rivers in classical cartography, the following method is used: rivers are represented as a solid line with a gradual thickening (depending on the number of tributaries that flow into the river) from the source to the mouth of the river. Moreover, segments of the river network often need to be ranked by the degree of distance from the source. This type of information is important not only for visualization, but also for a more complete perception of the data structure, its spatial distribution, and subsequent processing.

The problem of ranking rivers can be illustrated as follows (Fig. 1):

Image for post

Figure 1. Ranking rivers task, numbers indicate the attribute assigned to each segment of the river network for the total number of tributaries flowing in

Thus, each segment of the river needs to be mapped to a value that shows how many segments flow into this section.

Modern GIS, such as ArcGIS or its open-source competitor QGIS, have tools for working with river networks. However, the river ranking tool requires a large number of additional auxiliary materials and, as it seems to us, unnecessary transformations. For example, for an existing GIS tool to start working with river networks you need to prepare a digital elevation model. A significant disadvantage, in addition to complex and multi-stage data preparation, is the inability to use already prepared vector layers with a river network for analysis, which limits the possibility of using digital bases from open sources (OpenStreetMap or Natural Earth).

Of course, you can assign attribute values to segments without using algorithms, but this approach is no longer relevant if you need to rank the network with several thousand segments.

We decided to automate this procedure by representing the river network as a graph and then applying graph traversal algorithms. To simplify the user’s work with the implemented algorithm, a plugin for the QGIS geoinformation system — “Lines Ranking” was written. The code is distributed freely and is available in the QGIS repository, as well as on GitHub.

Installation

The plugin requires QGIS version >= 3.14, as well as the following dependencies: python libraries — networkx, pandas.

For Linux:

$ locate pip3

$ cd

$ pip3 install pandas

$ pip3 install networkx

For Windows:

In command line OSGeo4W:

$ pip install pandas

$ pip install networkx

Using

Input data is a vector layer consisting of objects with a linear geometry type (Line, MultiLine). Custom attributes are stored in the input layer to the output layer.

We do not recommend using a field named “fid” for the input layer. At the stage of connecting gaps in the river network, using the built — in module of the GRASS package- v.clean where this field name is the “system” one.

Also, an obligatory input parameter is a point (Start Point Coordinates) that determines the position of the mouth of the river network. It can be set from the map, from a file, or from a layer uploaded to QGIS. The position of the river mouth can be approximate. The calculation is based on the segment of the river network closest to the point (the closing vertex of the future graph).

Optional input data:

  • the threshold for “tightening” gaps in the river network (Spline Threshold). This operation involves the use of a package of GRASS for QGIS. If the specified package is missing, you should fix the gaps in another way and leave this field empty;
  • custom field names for the output layer. Allows the user to assign a field name to record the rank of each segment (Rank fieldname), the number of tributaries (Flow field name), and the distance from the mouth in meters (Distance field name). If parameters are not set , the default names of the fields are Rank, Value, and Distance;
  • location of the output file. If this parameter is omitted, a temporary layer will be created and added to the QGIS layer stack;

We can define the task performed by the algorithm as follows: compare the total number of tributaries flowing into each segment of the river, calculate the number of tributaries for each segment, as well as the distance of the farthest point of the segment from the mouth.

Algorithm description

In GIS, data can be presented in two main formats: raster and vector. A raster is a matrix where a certain parameter value is stored in each pixel. Satellite images, reanalysis grids, various output layers from climate models, and others are often represented in raster format in environmental science. Vector data is represented as simple geometric objects, such as points, lines, and polygons. Each object in a vector format can be associated with some information in the form of attributes. All the actions described below will be performed on the vector layer of the river network.

As a result, the algorithm returns a vector layer in which each object is assigned attributes that determine the distance of segments from the river mouth and the total number of tributaries that flow into this segment.

#graph #hydrology #qgis #ranking-algorithm #algorithms

Ruby on Rails Development Services | Ruby on Rails Development

Ruby on Rails is a development tool that offers Web & Mobile App Developers a structure for all the codes they write resulting in time-saving with all the common repetitive tasks during the development stage.

Want to build a Website or Mobile App with Ruby on Rails Framework

Connect with WebClues Infotech, the top Web & Mobile App development company that has served more than 600 clients worldwide. After serving them with our services WebClues Infotech is ready to serve you in fulfilling your Web & Mobile App Development Requirements.

Want to know more about development on the Ruby on Rails framework?

Visit: https://www.webcluesinfotech.com/ruby-on-rails-development/

Share your requirements https://www.webcluesinfotech.com/contact-us/

View Portfolio https://www.webcluesinfotech.com/portfolio/

#ruby on rails development services #ruby on rails development #ruby on rails web development company #ruby on rails development company #hire ruby on rails developer #hire ruby on rails developers

Ruth  Nabimanya

Ruth Nabimanya

1621327800

Graphs and Knowledge Connexions. The Year of the Graph Newsletter, Autumn 2020

As 2020 is coming to an end, let’s see it off in style. Our journey in the world of Graph Analytics, Graph Databases, Knowledge Graphs and Graph AI culminate.

The representation of the relationships among data, information, knowledge and --ultimately-- wisdom, known as the data pyramid, has long been part of the language of information science. Digital transformation has made this relevant beyond the confines of information science. COVID-19 has brought years’ worth of digital transformation in just a few short months.

In this new knowledge-based digital world, encoding and making use of business and operational knowledge is the key to making progress and staying competitive. So how do we go from data to information, and from information to knowledge? This is the key question Knowledge Connexions aims to address.

Graphs in all shapes and forms are a key part of this.


Knowledge Connexions is a visionary event featuring a rich array of technological building blocks to support the transition to a knowledge-based economy: Connecting data, people and ideas, building a global knowledge ecosystem.

The Year of the Graph will be there, in the workshop “From databases to platforms: the evolution of Graph databases”. George Anadiotis, Alan Morrison, Steve Sarsfield, Juan Sequeda and Steven Xi bring many years of expertise in the domain, and will analyze Graph Databases from all possible angles.

This is the first step in the relaunch of the Year of the Graph Database Report. Year of the Graph Newsletter subscribers just got a 25% discount code. To be always in the know, subscribe to the newsletter, and follow the newly launched Year of the Graph account on Twitter! In addition to getting the famous YotG news stream every day, you will also get a 25% discount code.

#database #machine learning #artificial intelligence #data science #graph databases #graph algorithms #graph analytics #emerging technologies #knowledge graphs #semantic technologies