Skip to content

Commit

Permalink
Incremental progress, all relations documented
Browse files Browse the repository at this point in the history
  • Loading branch information
CoralineAda committed Aug 1, 2024
1 parent e19fa3e commit 88e7d61
Show file tree
Hide file tree
Showing 104 changed files with 6,838 additions and 7,747 deletions.
1 change: 1 addition & 0 deletions app/jobs/category_extractor_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This background job performs the Category derivation process.
class CategoryExtractorJob

include Sidekiq::Job
Expand Down
1 change: 1 addition & 0 deletions app/jobs/export_to_graph_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This background job hydrates the graph from a SurveyResponse.
class ExportToGraphJob

include Sidekiq::Job
Expand Down
1 change: 1 addition & 0 deletions app/jobs/keyword_extractor_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This background job performs the Keyword extraction process.
class KeywordExtractorJob

include Sidekiq::Job
Expand Down
6 changes: 2 additions & 4 deletions app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Category

has_many :out, :codes, rel_class: :CategorizedAs, dependent: :delete_orphans

# This is the prompt sent to the selected AI agent to provide instructions on category derivision.
PROMPT = %{
You are a social researcher doing data analysis. Please generate a list of the 20 most relevant themes from the following list of codes. The themes should be all lowercase and contain no punctuation. Codes should be stripped of quotation marks. Return each code with an array of its categories in JSON format. Use this JSON as the format:
Expand All @@ -33,10 +34,6 @@ class Category
# Regenerates Category objects based on codes within a given context.
# This method uses the Clients::OpenAi client passing the codes as an argument to the prompt.
# The agent returns an array of themes, which are then captured as Category objects.
#
# @param context [String] the context value to use to filter codes for categorization.
# @return [String] the JSON response returned by the API.

def self.from(context)
codes = Code.where(context: context)
response = Clients::OpenAi.request("#{PROMPT} #{codes.map(&:name).join(',')}")
Expand All @@ -54,6 +51,7 @@ def self.from(context)

end

# Generates a hash with the unique category name as the key and the count of its associated codes as a value.
def self.histogram(context)
where(context: context).inject({}) { |acc, category| acc[category.name] = category.codes.count; acc }
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/code.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# A Code is a label applied to a group of related responses within a provided context.
# For example, a Code like "self-reflects" may be be applied to one or more responses to the Age Experience question.

class Code
include ActiveGraph::Node

Expand All @@ -14,6 +17,7 @@ class Code
has_many :out, :personas, rel_class: :Experiences
has_many :in, :categories, rel_class: :CategorizedAs

# Given a context, generates a hash with unique Codes as keys and the counts of its uses as values.
def self.histogram(context)
context = context.gsub("_exp","").gsub("klass","class").gsub("_","-")
where(context: context).query_as(:t).with('t, count{(t)-[:EXPERIENCES]-()} AS c').where('c > 0').order('c DESC').return('t.name, c').inject({}) {|h,t| h[t.values[0]] ||= 0; h[t.values[0]] += t.values[1]; h}
Expand Down
3 changes: 3 additions & 0 deletions app/models/codebook.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# A Codebook is a collection of codes applied to a given context.

class Codebook

# Used to label and display a Category query.
def self.category_query(context)
{
explainer: "// Show me a graph of \"#{context}\"-related categories and their associated codes.",
Expand Down
2 changes: 2 additions & 0 deletions app/models/experiences.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Experiences defines the unique relation (edge) between a Persona and a Code.

class Experiences

include ActiveGraph::Relationship
Expand Down
1 change: 1 addition & 0 deletions app/models/identifies_with.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# IdentifiesWith defines the unique relation (edge) between a Persona and an Identity.
class IdentifiesWith

include ActiveGraph::Relationship
Expand Down
2 changes: 2 additions & 0 deletions app/models/reflects_on.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ReflectsOn defines the unique relation (edge) between a Persona and a Keyword.

class ReflectsOn

include ActiveGraph::Relationship
Expand Down
150 changes: 62 additions & 88 deletions doc/ApplicationCable.html
Original file line number Diff line number Diff line change
@@ -1,117 +1,91 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: ApplicationCable

&mdash; Documentation by YARD 0.9.36

</title>

<link rel="stylesheet" href="css/style.css" type="text/css" />
<html>
<head>
<meta charset="UTF-8">

<link rel="stylesheet" href="css/common.css" type="text/css" />
<title>module ApplicationCable - RDoc Documentation</title>

<script type="text/javascript">
pathId = "ApplicationCable";
relpath = '';
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>

<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">


<body id="top" role="document" class="module">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>

<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>

<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

<script type="text/javascript" charset="utf-8" src="js/app.js"></script>


</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="class_list.html?1"></iframe>
<div id="resizer"></div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>

<div id="main" tabindex="-1">
<div id="header">
<div id="menu">

<a href="_index.html">Index (A)</a> &raquo;


<span class="title">ApplicationCable</span>

<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>

<div id="search">

<a class="full_list_link" id="class_list_link"
href="class_list.html">

<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>

</div>
<div class="clear"></div>
</div>
</div>

<div id="content"><h1>Module: ApplicationCable



</h1>
<div class="box_info">











<dl>
<dt>Defined in:</dt>
<dd>app/channels/application_cable/channel.rb<span class="defines">,<br />
app/channels/application_cable/connection.rb</span>
</dd>
</dl>

</div>

<h2>Defined Under Namespace</h2>
<p class="children">

<div id="class-metadata">



<strong class="classes">Classes:</strong> <span class='object_link'><a href="ApplicationCable/Channel.html" title="ApplicationCable::Channel (class)">Channel</a></span>, <span class='object_link'><a href="ApplicationCable/Connection.html" title="ApplicationCable::Connection (class)">Connection</a></span>


</p>


</div>
</nav>

<main role="main" aria-labelledby="module-ApplicationCable">
<h1 id="module-ApplicationCable" class="module">
module ApplicationCable
</h1>

<section class="description">

</section>

<section id="5Buntitled-5D" class="documentation-section">





</section>
</main>

</div>

<div id="footer">
Generated on Sun Jun 16 23:22:26 2024 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.36 (ruby-3.2.2).
</div>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

</div>
</body>
</html>
Loading

0 comments on commit 88e7d61

Please sign in to comment.