Module: Perseus
- Defined in:
- lib/perseus.rb,
lib/perseus/corpora.rb,
lib/perseus/helpers.rb,
lib/perseus/passage.rb,
lib/perseus/version.rb,
lib/perseus/constants.rb,
lib/perseus/index_xml.rb,
lib/perseus/dictionary.rb,
lib/perseus/corpus_hash.rb,
lib/perseus/cts_element.rb,
lib/perseus/file_index_xml.rb,
lib/perseus/corpus_references.rb,
lib/perseus/network_index_xml.rb
Defined Under Namespace
Classes: CTSElement, Corpora, CorpusHash, CorpusReferences, Dictionary, FileIndexXML, IndexXML, NetworkIndexXML, Passage
Constant Summary collapse
- VERSION =
"0.0.1"
- CTS_PFX =
"http://www.perseus.tufts.edu/hopper/CTS?request="
- DATA_DIR =
Pathname.new(__FILE__).join("../../../data")
- CTS_XML_FILE =
"#{DATA_DIR}/perseus-index.xml"
- CTS_BY_GROUP_JSON_FILE =
"#{DATA_DIR}/perseus-index-by-group.json"
- ALL_EDITIONS_JSON =
"#{DATA_DIR}/perseus-index-by-edition.json"
Class Method Summary collapse
- .print_corpus(texts) ⇒ Object
- .print_corpus_info(groupname, type, title, urn, language, description = nil) ⇒ Object
- .print_editions(editions) ⇒ Object
Class Method Details
.print_corpus(texts) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/perseus/helpers.rb', line 7 def self.print_corpus texts texts.each do |t| groupname = t.groupname t.work.each_with_index do |work, i| begin # Check if we have many editions unless work["edition"].nil? language = work["xml:lang"] if work.edition.kind_of?(Array) work.edition.each do |edition| title = edition.label urn = edition.urn desc = edition.description print_corpus_info groupname, "edition", title, urn, language.green, desc end else title = work.title urn = work.edition.urn desc = work.edition.description print_corpus_info groupname, "edition", title, urn, language.green end end # Check to see if we have translations unless work["translation"].nil? # Check if we have many translations if work.translation.kind_of?(Array) work.translation.each do |translation| title = translation.label urn = translation.urn language = translation["xml:lang"] print_corpus_info groupname, "translation", title, urn, language.redish end else title = work.title urn = work.translation.urn language = work.translation["xml:lang"] print_corpus_info groupname, "translation", title, urn, language.redish end end rescue Exception => e puts "exception: #{e..red}" #puts "Stack trace: #{backtrace.map {|l| " #{l}\n"}.join}" puts "We were working in group: #{groupname.cyan} with the following data point:".green puts work.inspect.yellow end end end end |
.print_corpus_info(groupname, type, title, urn, language, description = nil) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/perseus/helpers.rb', line 56 def self.print_corpus_info groupname, type, title, urn, language, description = nil puts "#{groupname} - #{title.purple}: #{urn.yellow}, #{type}: #{language}" unless description.nil? puts description.cyan end end |
.print_editions(editions) ⇒ Object
2 3 4 5 6 |
# File 'lib/perseus/helpers.rb', line 2 def self.print_editions editions editions.each do |edition| print_corpus_info edition.groupname, edition.type, edition.label, edition.urn, edition.language.green, edition.description end end |