Skip to content

Commit

Permalink
Hapi.HXL.quod_obiectum_optionem_existendum(), _chaves_relevantes()
Browse files Browse the repository at this point in the history
HXL-CPLP/forum#58, hapi-t9n-alpha (#13), mvp-l10n-schemas (#7)
  • Loading branch information
fititnt committed May 29, 2021
1 parent d864113 commit e2afced
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 13 deletions.
10 changes: 9 additions & 1 deletion _data/referens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ hxl:
ignorandum:
hashtag:
- '#meta'
# - '#status'
attributum:
- '+meta'
# - '+meta'
referens:
- '#item+id'

Expand All @@ -68,8 +69,10 @@ linguam:
- "+i_ar"
hxl:
attributum:
- "+i_ar+i_arb+is_arab"
- "+i_arb+is_arab"
- "+i_arb"
- "+i_ar+i_ara+is_arab"
- "+i_ara+is_arab"
- "+i_ara"
- "+i_ar"
Expand All @@ -81,6 +84,7 @@ linguam:
- "+i_en"
hxl:
attributum:
- "+i_en+i_eng+is_latn"
- "+i_eng+is_latn"
- "+i_eng"
- "+i_en"
Expand All @@ -92,6 +96,7 @@ linguam:
- "+i_es"
hxl:
attributum:
- "+i_es+i_spa+is_latn"
- "+i_spa+is_latn"
- "+i_spa"
- "+i_es"
Expand All @@ -106,11 +111,14 @@ linguam:
por-Latn:
BCP47: pt
hxlattrs: # deprecated
- "+i_pt+i_por+is_latn"
- "+i_por+is_latn"
- "+i_por"
- "+i_pt"
hxl:
attributum:
#item+i_pt+i_por+is_latn
- "+i_pt+i_por+is_latn"
- "+i_por+is_latn"
- "+i_por"
- "+i_pt"
Expand Down
2 changes: 1 addition & 1 deletion _data/tm/hapi-api.tm.hxl.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#item+id,#status,#item+type+lat_dominium+list,#item+item+type+lat_regnum,#item+item+type+lat_divisionem,#item+item+type+lat_classem,#item+item+type+lat_ordinem,#item+item+type+lat_familiam,#item+item+type+lat_genus,#item+item+type+lat_speciem,#item+type+lat_segmentum,#item+wikidata+code,#item+i_la+i_lat+is_latn,#item+i_pt+i_por+is_latn,#item+i_en+i_eng+is_latn,#item+i_es+i_spa+is_latn
#item+id,#status,#item+type+lat_dominium+list,#item+type+lat_regnum,#item+type+lat_divisionem,#item+type+lat_classem,#item+type+lat_ordinem,#item+type+lat_familiam,#item+type+lat_genus,#item+type+lat_speciem,#item+type+lat_segmentum,#item+wikidata+code,#item+i_la+i_lat+is_latn,#item+i_pt+i_por+is_latn,#item+i_en+i_eng+is_latn,#item+i_es+i_spa+is_latn
L10N_linguam_ego_summarius,1,L10N,L10N,linguam,,,,ego,summarius,,,Lingua Latina (Abecedarium Latinum),English language (Latin script),Língua portuguesa (alfabeto latino),
Hapi_api_UN_HDX_titulum,1,,Hapi,api,UN,HDX,,,titulum,,,,HDX - Intercâmbio de Dados Humanitários,HDX - The Humanitarian Data Exchange API,
Hapi_api_UN_HDX_slug,1,,Hapi,api,UN,HDX,,,slug,,,,humanitarian-data-exchange,humanitarian-data-exchange,
Expand Down
2 changes: 1 addition & 1 deletion _data/tm/hapi-schemam.tm.hxl.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#item+id,#status,#item+type+lat_dominium+list,#item+item+type+lat_regnum,#item+item+type+lat_divisionem,#item+item+type+lat_classem,#item+item+type+lat_ordinem,#item+item+type+lat_familiam,#item+item+type+lat_genus,#item+item+type+lat_speciem,#item+type+lat_segmentum,#item+wikidata+code,#item+i_la+i_lat+is_latn,#item+i_pt+i_por+is_latn,#item+i_en+i_eng+is_latn,#item+i_es+i_spa+is_latn
#item+id,#status,#item+type+lat_dominium+list,#item+type+lat_regnum,#item+type+lat_divisionem,#item+type+lat_classem,#item+type+lat_ordinem,#item+type+lat_familiam,#item+type+lat_genus,#item+type+lat_speciem,#item+type+lat_segmentum,#item+wikidata+code,#item+i_la+i_lat+is_latn,#item+i_pt+i_por+is_latn,#item+i_en+i_eng+is_latn,#item+i_es+i_spa+is_latn
L10N_linguam_ego_summarius,1,L10N,L10N,linguam,,,,ego,summarius,,,Lingua Latina (Abecedarium Latinum),English language (Latin script),Língua portuguesa (alfabeto latino),
ISO_639-3_nomen,1,,,ISO,639-3,,,,nomen,,,ISO 639-3,ISO 639-3,ISO 639-3,
ISO_639-3_summarius,1,,,ISO,639-3,,,,summarius,,,,Conjuntos de códigos para um número de sistemas de escrita – Parte 3:códigos Alpha-3 para cobertura abrangente de idiomas,Codes for the representation of names of languages – Part 3: Alpha-3 code for comprehensive coverage of languages,
Expand Down
126 changes: 117 additions & 9 deletions _plugins/hapi/hxl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
# - 'existendum'
# - https://en.wiktionary.org/wiki/existo#Latin

# require 'logger'

module Hapi
# _[eng] Rudimentar HXL utils for Hapi. [eng]_
# _[por] Utilitários HXL para Hapi. [por]_
Expand All @@ -48,7 +50,7 @@ def optionem_de_linguam(contextum, linguam = nil)
end

# TODO: 'quod obiectum attribūtum existendum?' tá mal traduzido
def quod_obiectum_optionem_existendum(obiectum, hxloptionem)
def quod_obiectum_optionem_existendum(_obiectum, _hxloptionem)
# puts 'hxloptionem obiectum'

# puts hxloptionem
Expand All @@ -64,7 +66,7 @@ def quod_obiectum_optionem_existendum(obiectum, hxloptionem)
true
end

def testum(obiectum, hxlattrs)
def testum(_obiectum, hxlattrs)
# puts 'testum'
# puts obiectum
# puts hxlattrs
Expand All @@ -76,12 +78,15 @@ def testum(obiectum, hxlattrs)
# _data/referens.yml to what is likely to be desired column
# [eng]_
class HXLOptionem
attr_accessor :attributum, :hashtag, :ignorandum, :referens
attr_accessor :attributum, :hashtag, :ignorandum_hashtag, :ignorandum_attributum, :referens

def initialize(attributum = nil, hashtag = nil, ignorandum = nil, referens = ['#item+id'] )
def initialize(attributum = nil, hashtag = nil, ignorandum = nil, referens = ['#item+id'])
@attributum = attributum
@hashtag = hashtag
@ignorandum = ignorandum
@ignorandum_hashtag = ignorandum.nil? || ignorandum['hashtag'].nil? ? nil : ignorandum['hashtag']
@ignorandum_attributum = ignorandum.nil? || ignorandum['attributum'].nil? ? nil : ignorandum['attributum']
# @ignorandum_attributum = ignorandum&.attributum
# @ignorandum = ignorandum
@referens = referens
end

Expand All @@ -102,10 +107,113 @@ def hashtag_exemplum
# - https://en.wiktionary.org/wiki/columna#Latin
# def quod_columnam(obiectum)
def quod_obiectum_optionem_existendum(obiectum)
puts 'quod_columnam'
puts obiectum.keys
# puts obiectum
false
opts = _chaves_relevantes(obiectum)
uglyhack = hashtag_exemplum
# puts 'quod_columnam'
# puts ''
# puts ''
# puts ''
# puts ' referens'
# puts @referens
# puts ' opts'
# puts opts
# puts ' uglyhack'
# puts uglyhack
# # puts obiectum.keys
# # puts opt
# # puts obiectum

# puts ' opts.any?'
# # puts opts.any? @referens

unless @referens.any? { |ref| opts.include?(ref) }
# log.debug("Created Logger")
puts "Hapi.HXL.HXLOptionem: non referens [#{referens}]"
return false
end
unless uglyhack.any? { |ref| opts.include?(ref) }
# puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}]"
puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}][#{opts}]"
# log.debug("Created Logger")
return false
end

# puts 'encontrou'
true
end

# Trivia:
# - 'valendum'
# - https://en.wiktionary.org/wiki/valeo#Latin
def quod_obiectum_valendum(obiectum, referens)
# opts = _chaves_relevantes(obiectum)

@referens.each do |key|
# unless obiectum[key].nil? || obiectum[key] != referens
# return true
# end
return obiectum[key] unless obiectum[key].nil? || obiectum[key] != referens

# TODO: agora procure a chave certa, nao retorne a mesma key :)
end

return false

# uglyhack = hashtag_exemplum
# # puts 'quod_columnam'
# # puts ''
# # puts ''
# # puts ''
# # puts ' referens'
# # puts @referens
# # puts ' opts'
# # puts opts
# # puts ' uglyhack'
# # puts uglyhack
# # # puts obiectum.keys
# # # puts opt
# # # puts obiectum

# # puts ' opts.any?'
# # # puts opts.any? @referens

# unless @referens.any? { |ref| opts.include?(ref) }
# # log.debug("Created Logger")
# puts "Hapi.HXL.HXLOptionem: non referens [#{referens}]"
# return false
# end
# unless uglyhack.any? { |ref| opts.include?(ref) }
# # puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}]"
# puts "Hapi.HXL.HXLOptionem: non obiectum_optionem [#{uglyhack}][#{opts}]"
# # log.debug("Created Logger")
# return false
# end

# # puts 'encontrou'
# true
"TODO retorna valor exato se existir"
end

private

def _chaves_relevantes(obiectum)
obiectum.keys

# obiectum.keys.select do |item|
# unless @ignorandum_hashtag.nil?
# @ignorandum_hashtag.each do |ig_hash|
# # puts " #{item}"
# return false if item.start_with?(ig_hash)
# end
# end
# unless @ignorandum_attributum.nil?
# @ignorandum_attributum.each do |ig_attr|
# return false if item.include?(ig_attr)
# end
# end

# true
# end
end
end
end
Expand Down
13 changes: 12 additions & 1 deletion _plugins/jekyll_hapi_translationem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def translationem_memoriam_collectionem(contextum)
contextum['site']['data']['tm']
end

def translationem_memoriam_rememorandum(contextum, _codicem, linguam = nil)
def translationem_memoriam_rememorandum(contextum, codicem, linguam = nil)
tm = translationem_memoriam_collectionem(contextum)
# hxlattrs = HXL.hxlattrs_de_linguam(contextum, linguam)
hxloptionem = HXL.optionem_de_linguam(contextum, linguam)
Expand All @@ -341,6 +341,15 @@ def translationem_memoriam_rememorandum(contextum, _codicem, linguam = nil)
# raise 'stop'
next unless hxloptionem.quod_obiectum_optionem_existendum(tm[archivum[0]][0])

puts 'valido, continuando...'

tm[archivum[0]].each do |tm_item|
val = hxloptionem.quod_obiectum_valendum(tm_item, codicem)
# puts 'val'
puts "#{codicem}, #{linguam}: #{val}" unless val == false
return val unless val == false
end

# archivum.each do |tm_item|
# # puts hxlattr
# next unless HXL.testum(tm_item, hxloptionem)
Expand All @@ -350,6 +359,8 @@ def translationem_memoriam_rememorandum(contextum, _codicem, linguam = nil)

# return HXL.testum(tm_item, hxloptionem)
# end

false
end

# puts 'hxlattrs'
Expand Down

0 comments on commit e2afced

Please sign in to comment.