Skip to content

Commit

Permalink
refactor: ♻️ All analysis types into constants, not their own files
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Oct 26, 2021
1 parent 2e88f2c commit 77d6dc6
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 233 deletions.
41 changes: 0 additions & 41 deletions src/Algorithms/Centrality.ts

This file was deleted.

44 changes: 0 additions & 44 deletions src/Algorithms/LinkPrediction.ts

This file was deleted.

34 changes: 0 additions & 34 deletions src/Algorithms/Similarity.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/AnalysisView.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ItemView, WorkspaceLeaf } from 'obsidian'
import { ANALYSIS_TYPES, VIEW_TYPE_GRAPH_ANALYSIS } from 'src/Constants'
import { ANALYSIS_TYPES, VIEW_TYPE_GRAPH_ANALYSIS } from 'src/constants'
import type { Analyses } from 'src/Interfaces'
import type GraphAnalysisPlugin from 'src/main'
import { claim_component } from 'svelte/internal'
import CoCitations from './Components/CoCitations.svelte'
import LinkPrediction from './Components/LinkPrediction.svelte'
import Similarity from './Components/Similarity.svelte'
Expand Down
15 changes: 10 additions & 5 deletions src/Components/Centrality.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<script lang="ts">
import type { App } from 'obsidian'
import { openOrSwitch } from 'obsidian-community-lib'
import { CENTRALITY_TYPES } from 'src/Algorithms/Centrality'
import { openOrSwitch, linkedQ } from 'obsidian-community-lib'
import type AnalysisView from 'src/AnalysisView'
import { LINKED, NOT_LINKED, TD_MEASURE, TD_NODE } from 'src/Constants'
import {
CENTRALITY_TYPES,
LINKED,
NOT_LINKED,
TD_MEASURE,
TD_NODE,
} from 'src/constants'
import type { GraphAnalysisSettings, Subtypes } from 'src/Interfaces'
import type GraphAnalysisPlugin from 'src/main'
import { debug, dropPath, hoverPreview, linkedQ } from 'src/Utility'
import { debug, dropPath, hoverPreview } from 'src/Utility'
import { onMount } from 'svelte'
export let plugin: GraphAnalysisPlugin
Expand Down Expand Up @@ -85,7 +90,7 @@
<tr class={node.linked ? LINKED : NOT_LINKED}>
<td
class="internal-link {TD_NODE}"
on:click={(e) => openOrSwitch(app, node.to, currFile, e)}
on:click={(e) => openOrSwitch(app, node.to, e)}
on:mouseover={(e) => hoverPreview(e, view)}
>
{dropPath(node.to)}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/CoCitations.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import type { App } from 'obsidian'
import { openOrSwitch, linkedQ } from 'obsidian-community-lib'
import { linkedQ, openOrSwitch } from 'obsidian-community-lib'
import type AnalysisView from 'src/AnalysisView'
import { LINKED, NOT_LINKED, TD_MEASURE, TD_NODE } from 'src/Constants'
import { LINKED, NOT_LINKED, TD_MEASURE, TD_NODE } from 'src/constants'
import type { CoCitationRes, GraphAnalysisSettings } from 'src/Interfaces'
import type GraphAnalysisPlugin from 'src/main'
import {
Expand Down
11 changes: 8 additions & 3 deletions src/Components/LinkPrediction.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<script lang="ts">
import type { App } from 'obsidian'
import { openOrSwitch, linkedQ } from 'obsidian-community-lib'
import { LINK_PREDICTION_TYPES } from 'src/Algorithms/LinkPrediction'
import { linkedQ, openOrSwitch } from 'obsidian-community-lib'
import type AnalysisView from 'src/AnalysisView'
import { LINKED, NOT_LINKED, TD_MEASURE, TD_NODE } from 'src/Constants'
import {
LINKED,
LINK_PREDICTION_TYPES,
NOT_LINKED,
TD_MEASURE,
TD_NODE,
} from 'src/constants'
import type { GraphAnalysisSettings } from 'src/Interfaces'
import type GraphAnalysisPlugin from 'src/main'
import { debug, dropPath, hoverPreview, openMenu } from 'src/Utility'
Expand Down
11 changes: 8 additions & 3 deletions src/Components/Similarity.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<script lang="ts">
import type { App } from 'obsidian'
import { openOrSwitch, linkedQ } from 'obsidian-community-lib'
import { SIMILARITY_TYPES } from 'src/Algorithms/Similarity'
import { linkedQ, openOrSwitch } from 'obsidian-community-lib'
import type AnalysisView from 'src/AnalysisView'
import { LINKED, NOT_LINKED, TD_MEASURE, TD_NODE } from 'src/Constants'
import {
LINKED,
NOT_LINKED,
SIMILARITY_TYPES,
TD_MEASURE,
TD_NODE,
} from 'src/constants'
import type { GraphAnalysisSettings } from 'src/Interfaces'
import type GraphAnalysisPlugin from 'src/main'
import { debug, dropPath, hoverPreview, openMenu } from 'src/Utility'
Expand Down
42 changes: 26 additions & 16 deletions src/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
import type { Analyses, GraphAnalysisSettings } from "src/Interfaces";
import type { Analyses, GraphAnalysisSettings } from 'src/Interfaces'

export const DEFAULT_SETTINGS: GraphAnalysisSettings = {
noInfinity: true,
noZero: true,
defaultAnalysisType: 'Co-Citations',
debugMode: false,
superDebugMode: false,
noInfinity: true,
noZero: true,
defaultAnalysisType: 'Co-Citations',
debugMode: false,
superDebugMode: false,
}

export const DECIMALS = 4;
export const DECIMALS = 4

export const VIEW_TYPE_GRAPH_ANALYSIS = 'graph-analysis';
export const VIEW_TYPE_GRAPH_ANALYSIS = 'graph-analysis'

export const ANALYSIS_TYPES: Analyses[] = [
// 'Centrality',
'Link Prediction',
'Similarity',
'Co-Citations'
// 'Centrality',
'Link Prediction',
'Similarity',
'Co-Citations',
]

export const LINKED = 'analysis-linked';
export const NOT_LINKED = 'analysis-not-linked';
export const LINKED = 'analysis-linked'
export const NOT_LINKED = 'analysis-not-linked'

export const TD_MEASURE = 'analysis-measure';
export const TD_NODE = 'analysis-node';
export const TD_MEASURE = 'analysis-measure'
export const TD_NODE = 'analysis-node'

export const CENTRALITY_TYPES: {
subtype: string
}[] = [{ subtype: 'Closeness' }]

export const LINK_PREDICTION_TYPES: {
subtype: string
}[] = [{ subtype: 'Adamic Adar' }, { subtype: 'Common Neighbours' }]

export const SIMILARITY_TYPES: {
subtype: string
}[] = [{ subtype: 'Jaccard' }]
2 changes: 1 addition & 1 deletion src/MyGraph.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Graph } from 'graphlib'
import type { App, HeadingCache, ReferenceCache } from 'obsidian'
import tokenizer from 'sbd'
import { DECIMALS } from 'src/Constants'
import { DECIMALS } from 'src/constants'
import { nodeIntersection } from 'src/GeneralGraphFn'
import type {
AnalysisAlg,
Expand Down
Loading

0 comments on commit 77d6dc6

Please sign in to comment.