mpq1990 / Chaillot

0 stars 0 forks source link

Define Hash Algorithm, that assigns a particular character of the name of someone. #2

Open paschelino opened 5 years ago

paschelino commented 5 years ago

View: One simple form field, that validates to be not empty. Service endpoint: Receives an http post request with the non empty form field. Domain service: Takes the input and delivers the character and the character position.

paschelino commented 5 years ago

The declaration of human rights has been translated into more than 500 languages: https://www.ohchr.org/EN/UDHR/Pages/SearchByLang.aspx

To make the idea more concrete:

Feature: Associate human with the Universal Declaration of Human Rights
  In order to show support of a humanity with equal rights
  As a human being
  I want to associate myself with the declaration of human rights

  Scenario: Successfully Calculate My Association
    Given I open the form to associate myself with the universal declaration of human rights
    And the encoding is UTF-
    And I enter my personal data as follows:
      | First name   | Last name   | Date of birth (YYYY-MM-DD) | City of birth | Country of birth | Native Language |
      | Bertha       | von Suttner | 1843-06-09                 | Prague        | CZ               | de_AT           |
    When I request my association
    Then I receive my association to the declaration of human rights as follows
      | Character | Character position | Human Rights Translation |
      | a         | 9514               | de                       |

Let me describe the algorithmic idea in a ruby snippet, I tested in irb:

bill = File.read("./fixtures/human-rights-declarations/de.md").encode("utf-16be")
bill.length
# => 12170
bertha = "Bertha von Suttner 1843-06-09 Prague CZ de_AT".encode("utf-16be")
bertha.bytes.join("").to_i
# => 660101011401160104097032011801110110032083011701160116011001010114032049056052051045048054045048057032080011409701030117010103206709003201000101095065084
bertha.bytes.join("").to_i % bill.length
# => 9514
bill[9514]
# => "a"
paschelino commented 5 years ago

By the way (just learned, while trying to find a good example): Berta von Suttner:

Though her personal contact with Alfred Nobel had been brief, she corresponded with him until his death in 1896, and it is believed that she was a major influence on his decision to include a peace prize among those prizes provided in his will, which she was awarded in the fifth term on 10 December 1905. The presentation took place on 18 April 1906 in Kristiania.

paschelino commented 5 years ago

The file read in the snippet is in this PR: https://github.com/mpq1990/Chaillot/pull/4/files

paschelino commented 5 years ago

Open question: What shall we do with 'middle' names? My full name for example is Pascal Benedikt Erb.

paschelino commented 5 years ago

moved the source file with the bill of human rights to the client public folder.