Philologic::Client - Ruby client for interacting with the Philologic API.

Usage

require 'philologic-client'

Philologic::Client.new(endpoint) do |client|

  # Get/Set encoding
  encoding        = client.encoding 
  client.encoding = 'utf-8' # Default

  # Get/Set endpoint
  endpoint        = client.endpoint
  client.endpoint = 'http://philologic.example.org'

  # Get bibliography
  # +biblio+ is a Philologic::Client::Bibliography object
  biblio = client.bibliography

  # Get reference to first title
  # +first+ is a Philologic::Client::Occurrence object
  first  = biblio.titles.first

  # Get first title
  # +doc+ will be a Philologic::Client::Document object
  doc = client.document( first['href'] )

  # Get text if present
  if doc.text?
    txt  = doc.text # Document text
    html = doc.html # Document HTML
  end

  # Get links if present
  if doc.links?
    doc.links.each do |link|
     # +link+ is Philologic::Client::Link object
     link.url  # Link URL
     link.text # Link text
    end
  end

  # Get +Array+ of document property keys.
  doc.keys

  # Get document properties
  doc.each { |p| puts "%s\t%s" % [ p, doc[p] ] }

  # Collocation search
  # Returns Philologic::Client::Collocation object
  q = client.collocation('lion')

  # Get results if present.
  if q.results?
    q.results.each do |result|
      # +result+ is a Philologic::Client::CollocationRow object
    end
  end

  # Concordance search
  # Returns Philologic::Client::Concordance object
  q = client.concordance('lion')

  # Get results if present.
  if q.results?
    q.results.each do |result|
      # +result+ is a Philologic::Client::Occurrence object
    end 
  end

  # Frequency search
  # Returns Philologic::Client::Frequency object
  q = client.frequency('lion')

  # Get results if present
  if q.results?
    q.results.each do |result|
      # +result+ is a Philologic::Client::FrequencyRow object
    end
  end

end

Author

blair christensen. <[email protected]>

Homepage

github.com/blairc/philologic-client/

See Also

To Do

  • Collocation searches

  • Cache results?