Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update text model #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions grammars/basicdoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@
<data type="ID"/>
</attribute>
<attribute name="reviewer"/>
<optional>
<attribute name="type"/>
</optional>
<optional>
<attribute name="date">
<data type="dateTime"/>
Expand Down
124 changes: 71 additions & 53 deletions grammars/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<text/>
</element>
</define>
<define name="LocalizedString1">
<define name="LocalizedStringAttrs">
<optional>
<!-- multiple languages and scripts possible: comma delimit them if so -->
<attribute name="language"/>
Expand All @@ -106,6 +106,10 @@
<optional>
<attribute name="script"/>
</optional>
</define>
<define name="LocalizedString1">
<!-- multiple languages and scripts possible: comma delimit them if so -->
<ref name="LocalizedStringAttrs"/>
<text/>
</define>
<define name="LocalizedString">
Expand Down Expand Up @@ -142,16 +146,8 @@
<ref name="LocalizedStringOrXsAny"/>
</define>
<define name="LocalizedStringOrXsAny1">
<optional>
<!-- multiple languages and scripts possible: comma delimit them if so -->
<attribute name="language"/>
</optional>
<optional>
<attribute name="locale"/>
</optional>
<optional>
<attribute name="script"/>
</optional>
<!-- multiple languages and scripts possible: comma delimit them if so -->
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<choice>
<text/>
Expand Down Expand Up @@ -208,7 +204,10 @@
</define>
<define name="roledescription">
<element name="description">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="person">
Expand Down Expand Up @@ -333,34 +332,40 @@
</define>
<define name="affiliationdescription">
<element name="description">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="organization">
<element name="organization">
<oneOrMore>
<ref name="orgname"/>
</oneOrMore>
<zeroOrMore>
<ref name="subdivision"/>
</zeroOrMore>
<optional>
<ref name="abbreviation"/>
</optional>
<zeroOrMore>
<ref name="uri"/>
</zeroOrMore>
<zeroOrMore>
<ref name="org-identifier"/>
</zeroOrMore>
<zeroOrMore>
<ref name="contact"/>
</zeroOrMore>
<optional>
<ref name="logo"/>
</optional>
<ref name="OrganizationType"/>
</element>
</define>
<define name="OrganizationType">
<oneOrMore>
<ref name="orgname"/>
</oneOrMore>
<zeroOrMore>
<ref name="subdivision"/>
</zeroOrMore>
<optional>
<ref name="abbreviation"/>
</optional>
<zeroOrMore>
<ref name="uri"/>
</zeroOrMore>
<zeroOrMore>
<ref name="org-identifier"/>
</zeroOrMore>
<zeroOrMore>
<ref name="contact"/>
</zeroOrMore>
<optional>
<ref name="logo"/>
</optional>
</define>
<define name="orgname">
<element name="name">
<choice>
Expand All @@ -371,10 +376,10 @@
</define>
<define name="subdivision">
<element name="subdivision">
<choice>
<ref name="LocalizedString"/>
<ref name="NameWithVariants"/>
</choice>
<optional>
<attribute name="type"/>
</optional>
<ref name="OrganizationType"/>
</element>
</define>
<define name="logo">
Expand Down Expand Up @@ -894,7 +899,9 @@
</define>
<define name="formattedref">
<element name="formattedref">
<ref name="FormattedString"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="license">
Expand Down Expand Up @@ -939,7 +946,10 @@
<optional>
<attribute name="type"/>
</optional>
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<zeroOrMore>
<ref name="TextElement"/>
</zeroOrMore>
</define>
<!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
<define name="TypedUri">
Expand Down Expand Up @@ -1030,16 +1040,10 @@
<data type="boolean"/>
</attribute>
</optional>
<optional>
<attribute name="language"/>
</optional>
<optional>
<attribute name="locale"/>
</optional>
<optional>
<attribute name="script"/>
</optional>
<text/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="docnumber">
Expand Down Expand Up @@ -1264,12 +1268,23 @@
<optional>
<attribute name="type"/>
</optional>
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</define>
<define name="bibabstract">
<element name="abstract">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<choice>
<oneOrMore>
<ref name="BasicBlock"/>
</oneOrMore>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</choice>
</element>
</define>
<define name="copyright">
Expand Down Expand Up @@ -1374,7 +1389,10 @@
</attribute>
<optional>
<element name="description">
<ref name="FormattedString"/>
<ref name="LocalizedStringAttrs"/>
<oneOrMore>
<ref name="TextElement"/>
</oneOrMore>
</element>
</optional>
<element name="bibitem">
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_ieee/balloting_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def to_xml(builder)
#
# @return [Hash] balloting group as Hash
#
def to_hash
def to_h
{ "type" => type, "content" => content }
end

Expand Down
4 changes: 2 additions & 2 deletions lib/relaton_ieee/data_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def add_crossref(docnumber, amsid)
def save_doc(bib)
c = case @format
when "xml" then bib.to_xml(bibdata: true)
when "yaml" then bib.to_hash.to_yaml
when "yaml" then bib.to_h.to_yaml
else bib.send("to_#{@format}")
end
File.write file_name(bib.docnumber), c, encoding: "UTF-8"
Expand Down Expand Up @@ -194,7 +194,7 @@ def update_relations # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
def create_relation(type, fref) # rubocop:disable Metrics/MethodLength
return if RELATION_TYPES[type] == false

fr = RelatonBib::FormattedRef.new(content: fref)
fr = RelatonBib::FormattedRef.new(fref)
docid = RelatonBib::DocumentIdentifier.new(type: "IEEE", id: fref, primary: true)
bib = IeeeBibliographicItem.new formattedref: fr, docid: [docid]
desc = RELATION_TYPES[type][:description]
Expand Down
6 changes: 3 additions & 3 deletions lib/relaton_ieee/data_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def parse_contributor # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
ob << RelatonBib::Address.new(street: [], city: city, state: state, country: country)
end
e = create_org n, addr
RelatonBib::ContributionInfo.new entity: e, role: [type: "publisher"]
RelatonBib::Contributor.new entity: e, role: [type: "publisher"]
end
end

Expand Down Expand Up @@ -217,7 +217,7 @@ def parse_abstract
def parse_copyright
doc.xpath("./publicationinfo/copyrightgroup/copyright").map do |c|
owner = c.at("./holder").text.split("/").map do |own|
RelatonBib::ContributionInfo.new entity: create_org(own)
create_org(own)
end
RelatonBib::CopyrightAssociation.new(
owner: owner, from: c.at("./year").text,
Expand Down Expand Up @@ -263,7 +263,7 @@ def parse_relation # rubocop:disable Metrics/AbcSize
def parse_link
doc.xpath("./volume/article/articleinfo/amsid").map do |id|
l = "https://ieeexplore.ieee.org/document/#{id.text}"
RelatonBib::TypedUri.new content: l, type: "src"
RelatonBib::Source.new content: l, type: "src"
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/relaton_ieee/editorial_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def to_xml(builder)
#
# @return [Hash] editorial group as Hash
#
def to_hash
def to_h
hash = {}
hash["society"] = society if society
hash["balloting_group"] = balloting_group.to_hash if balloting_group
hash["balloting_group"] = balloting_group.to_h if balloting_group
hash["working_group"] = working_group if working_group
hash["committee"] = committee if committee
hash
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_ieee/ieee_bibliographic_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metr
#
# @return [Hash]
#
def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize
def to_h(embedded: false) # rubocop:disable Metrics/AbcSize
hash = super
hash["trialuse"] = trialuse unless trialuse.nil?
hash["ext"]["standard_status"] = standard_status unless standard_status.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_ieee/rawbib_id_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def parse(normtitle, stdnumber) # rubocop:disable Metrics/AbcSize, Metrics/Metho
PubId.new(publisher: $1, number: $2)

else
Util.warn %{Use stdnumber "#{stdnumber}" for nortitle "#{normtitle}"}
Util.warn %{Use stdnumber "#{stdnumber}" for normtitle "#{normtitle}"}
PubId.new(publisher: "IEEE", number: stdnumber)
end
rescue ArgumentError => e
Expand Down
Loading
Loading