Skip to content

Commit 698dcec

Browse files
committed
add algorithms
1 parent 406dc69 commit 698dcec

File tree

17 files changed

+350
-383
lines changed

17 files changed

+350
-383
lines changed

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function Home() {
1010

1111
<div className="flex flex-row mb-4 items-center">
1212
<Image src="/comparit_logo.svg" width={60} height={60} alt="logo"/>
13-
<h1 className="pl-[20px] text-3xl font-bold sm:text-6xl items-center">
13+
<h1 className="pl-[12px] text-3xl font-bold sm:text-6xl items-center">
1414
Comparit
1515
</h1>
1616
</div>

components/footer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export function Footer() {
2727
</p>
2828
</div>
2929

30-
<div className="gap-4 items-center hidden md:flex">
30+
{/* <div className="gap-4 items-center hidden md:flex">
3131
<FooterButtons />
32-
</div>
32+
</div> */}
3333
</div>
3434
</footer>
3535
);

components/navbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export function Navbar() {
7878

7979
export function Logo() {
8080
return (
81-
<Link href="/" className="flex items-center gap-2.5">
81+
<Link href="/" className="flex items-center gap-2">
8282
{/* <CommandIcon className="w-6 h-6 text-muted-foreground" strokeWidth={2} /> */}
8383
<Image src="/comparit_logo.svg" width={25} height={25} alt="logo"/>
84-
<h2 className="text-md font-bold font-code">Comparit</h2>
84+
<h2 className="text-[17px] font-bold font-code">Comparit</h2>
8585
</Link>
8686
);
8787
}

contents/blogs/article.mdx

Whitespace-only changes.
Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +0,0 @@
1-
---
2-
title: Custom Components
3-
description: How to create custom components for Markdown.
4-
---
5-
6-
To add custom components in AriaDocs, follow these steps:
7-
8-
1. **Create Your Component**: First, create your custom component in the `@components/markdown` folder. For example, you might create a file named `Outlet.tsx`.
9-
10-
2. **Import Your Component**: Next, open the `@lib/markdown.ts` file. This is where you'll register your custom component for use in Markdown.
11-
12-
3. **Add Your Component to the Components Object**: In the `@lib/markdown.ts` file, import your custom component and add it to the `components` object. Here’s how to do it:
13-
14-
```ts
15-
import Outlet from "@/components/markdown/outlet";
16-
17-
// Add custom components
18-
const components = {
19-
Outlet,
20-
};
21-
```
22-
23-
4. **Using Your Custom Component in Markdown**: After registering your component, you can now use it anywhere in your Markdown content. For instance, if your `Outlet` component is designed to display additional information, you can use it as follows:
24-
25-
### Markdown Example
26-
27-
```markdown
28-
<Outlet>
29-
This is some custom content rendered by the Outlet component!
30-
</Outlet>
31-
```
32-
33-
### Rendered Output
34-
35-
This will render the content inside the `Outlet` component, allowing you to create reusable and dynamic Markdown content.
36-
37-
38-
By following these steps, you can extend the capabilities of your Markdown documentation and create a more engaging user experience.
Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +0,0 @@
1-
---
2-
title: Image and Link
3-
description: This section provides an overview of how AriaDocs handles links and images in Markdown.
4-
---
5-
6-
In AriaDocs, all links and images written in Markdown are automatically converted to their respective Next.js components. This allows for better optimization and performance in your application.
7-
8-
## Links
9-
10-
When you create a link in your Markdown, it is converted to the Next.js `Link` component. This enables client-side navigation and improves loading times. Here’s an example of how a Markdown link is transformed:
11-
12-
### Markdown
13-
14-
```markdown
15-
[Visit OpenAI](https://www.openai.com)
16-
```
17-
18-
### Rendered Output
19-
20-
The above Markdown is converted to:
21-
22-
```jsx
23-
<Link href="https://www.openai.com" target="_blank" rel="noopener noreferrer">
24-
Visit OpenAI
25-
</Link>
26-
```
27-
28-
## Images
29-
30-
Similarly, images in Markdown are transformed into the Next.js `Image` component. This allows for automatic image optimization, such as lazy loading and resizing, which enhances performance and user experience. Here’s an example:
31-
32-
### Markdown
33-
34-
```markdown
35-
![Alt text for the image](https://via.placeholder.com/150)
36-
```
37-
38-
### Rendered Output
39-
40-
The above Markdown is converted to:
41-
42-
```jsx
43-
<Image
44-
src="https://via.placeholder.com/150"
45-
alt="Alt text for the image"
46-
width={800}
47-
height={350}
48-
/>
49-
```
50-
51-
## Benefits
52-
53-
- **Performance Optimization**: Automatic conversion to Next.js components ensures optimized loading of images and links.
54-
- **Improved User Experience**: Client-side navigation with Next.js `Link` improves the browsing experience.
55-
- **Responsive Images**: Next.js `Image` component handles responsive images, providing the best quality for various device sizes.
56-
57-
By utilizing these features, you can ensure that your documentation is not only visually appealing but also performs efficiently.
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
---
2-
title: Components
3-
description: This section provides an overview of the custom components available in AriaDocs.
4-
---
5-
6-
Explore the custom components we've defined for easy integration and development within your projects. Each component is designed to enhance your workflow and streamline your development process.
7-
8-
9-
<Outlet path="/getting-started/components" />
Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +0,0 @@
1-
---
2-
title: Stepper
3-
description: This section previews the stepper component.
4-
---
5-
6-
In this guide, we utilize a custom `Stepper` component, specifically designed for AriaDocs, which enables users to display step-by-step instructions directly within the markdown render.
7-
8-
## Preview
9-
##
10-
11-
<Stepper>
12-
<StepperItem title="Step 1: Clone the AriaDocs Repository">
13-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec interdum, felis sed efficitur tincidunt, justo nulla viverra enim, et maximus nunc dolor in lorem.
14-
</StepperItem>
15-
<StepperItem title="Step 2: Access the Project Directory">
16-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non neque ut eros auctor accumsan. Mauris a nisl vitae magna ultricies aliquam.
17-
</StepperItem>
18-
<StepperItem title="Step 3: Install Required Dependencies">
19-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ut ipsum nec nulla ultricies porttitor et non justo.
20-
</StepperItem>
21-
</Stepper>
22-
23-
## Code
24-
25-
```jsx
26-
<Stepper>
27-
<StepperItem title="Step 1: Clone the AriaDocs Repository">
28-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec interdum, felis sed efficitur tincidunt, justo nulla viverra enim, et maximus nunc dolor in lorem.
29-
</StepperItem>
30-
<StepperItem title="Step 2: Access the Project Directory">
31-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non neque ut eros auctor accumsan. Mauris a nisl vitae magna ultricies aliquam.
32-
</StepperItem>
33-
<StepperItem title="Step 3: Install Required Dependencies">
34-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ut ipsum nec nulla ultricies porttitor et non justo.
35-
</StepperItem>
36-
</Stepper>
37-
```
38-

contents/docs/getting-started/concepts/index.mdx

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,118 @@ of two models with respect to their meaning or semantics. From the perspective o
2727
versioning. Additionally, semantic comparison of models could automate the
2828
grading of software based assignments in academia; extracted models from
2929
the student’s work could be compared with the benchmark models to check
30-
the validity.
30+
the validity.
31+
32+
## Algorithms
33+
The tool provides an an abstract java class that could be extended to
34+
implement an algorithm of choice. The instance of the algorithm of choice is
35+
created and used to compare models as represented abstractly in Pseudocode 1.
36+
37+
### Pseudocode 1
38+
<img src="/compare_modles_uing_algo_of_choice.png" alt="Image alt" />
39+
40+
The compareModels function expects a hashmap (config) that contains information about the granularity of comparison and choice of algorithm. The
41+
hashmap can contain the configuration variables listed in the table below.
42+
43+
### Configuration Table
44+
| **Property** | **Type** | **Default Value** | **Description** |
45+
|--------------|-----------|-------------------|-----------------|
46+
| USE-HASHING | boolean | true | Whether to use hashing in the comparison |
47+
| INCLUDE-DEPENDENCIES | boolean | true | Whether to include dependencies in the comparison |
48+
| MODEL-LEVEL-COMPARISON-DERIVED-FROM-CLASS-LEVEL-COMPARISON | boolean | true | Model-level comparison derived from class-level comparison. If false, elements will be compared on model level |
49+
| HASHING-THRESHOLD | number | 0.5 | The threshold for hashing similarity |
50+
| INCLUDE-ENUMS | boolean | true | Whether to include enums in the comparison |
51+
| INCLUDE-ENUM-NAME | boolean | true | Whether to include enum names in the comparison |
52+
| INCLUDE-CLASS-ATTRIBUTES | boolean | true | Whether to include class attributes in the comparison |
53+
| INCLUDE-CLASS-OPERATIONS | boolean | true | Whether to include class operations in the comparison |
54+
| INCLUDE-CLASS-PARAMETERS | boolean | true | Whether to include class parameters in the comparison |
55+
| INCLUDE-CLASS-REFERENCES | boolean | true | Whether to include class references in the comparison |
56+
| INCLUDE-CLASS-SUPERTYPES | boolean | true | Whether to include class supertypes in the comparison |
57+
| INCLUDE-ATTRIBUTE-NAME | boolean | true | Whether to include attribute names in the comparison |
58+
| INCLUDE-ATTRIBUTE-CONTAINING-CLASS | boolean | true | Whether to include the class containing the attribute in the comparison |
59+
| INCLUDE-ATTRIBUTE-TYPE | boolean | true | Whether to include attribute types in the comparison |
60+
| INCLUDE-ATTRIBUTE-LOWER-BOUND | boolean | true | Whether to include attribute lower bounds in the comparison |
61+
| INCLUDE-ATTRIBUTE-UPPER-BOUND | boolean | true | Whether to include attribute upper bounds in the comparison |
62+
| INCLUDE-ATTRIBUTE-IS-ORDERED | boolean | true | Whether to include if the attribute is ordered |
63+
| INCLUDE-ATTRIBUTE-IS-UNIQUE | boolean | true | Whether to include if the attribute is unique |
64+
| INCLUDE-REFERENCES-NAME | boolean | true | Whether to include reference names in the comparison |
65+
| INCLUDE-REFERENCES-CONTAINING-CLASS | boolean | true | Whether to include the class containing the reference in the comparison |
66+
| INCLUDE-REFERENCES-IS-CONTAINMENT | boolean | true | Whether to include if the reference is containment |
67+
| INCLUDE-REFERENCES-LOWER-BOUND | boolean | true | Whether to include reference lower bounds in the comparison |
68+
| INCLUDE-REFERENCES-UPPER-BOUND | boolean | true | Whether to include reference upper bounds in the comparison |
69+
| INCLUDE-REFERENCES-IS-ORDERED | boolean | true | Whether to include if the reference is ordered |
70+
| INCLUDE-REFERENCES-IS-UNIQUE | boolean | true | Whether to include if the reference is unique |
71+
| INCLUDE-OPERATION-NAME | boolean | true | Whether to include operation names in the comparison |
72+
| INCLUDE-OPERATION-CONTAINING-CLASS | boolean | true | Whether to include the class containing the operation in the comparison |
73+
| INCLUDE-OPERATION-PARAMETERS | boolean | true | Whether to include operation parameters in the comparison |
74+
| INCLUDE-PARAMETER-NAME | boolean | true | Whether to include parameter names in the comparison |
75+
| INCLUDE-PARAMETER-TYPE | boolean | true | Whether to include parameter types in the comparison |
76+
| INCLUDE-PARAMETER-OPERATION-NAME | boolean | true | Whether to include the operation name associated with the parameter in the comparison |
77+
78+
Based on the choice of algorithm, if implemented in the tool, the relevant instance
79+
of the class is initialized; that instance is named as ”alg”. The function
80+
”getClassLevelMetrics” is called that uses the instance of the algorithm to
81+
compute the ven diagram for each of the elements of the model. The ven
82+
diagram provides information about the true positives, false positives, and
83+
false negatives. if the MODEL-LEVEL-COMPARISON-DERIVED-FROM-
84+
CLASS-LEVEL-COMPARISON configuration variable (refer to configuration table) is set to True then the classLevelMetrics and the Ven Diagram
85+
for enumerations (computed separately because they are present at the root
86+
of the model instead of being part of a class), are used to generate the the
87+
model level metrics; else, the model level metrics are generated by comparing model elements on model level. We have not described the functions ”get-
88+
ConfusionMatrixForAllElements()” and ”getMLM(clm, VDEnum”)because
89+
they are trivial.
90+
91+
## Hashing Based Algorithm
92+
The hashing based algorithm has been implemented as an extension of the
93+
abstract model comparison class. The inspiration for this algorithm
94+
comes from the [Xiao He’s paper](https://www.researchgate.net/publication/380177673_Accelerating_similarity-based_model_matching_using_dual_hashing); an extension of EMF-Compare. Our
95+
algorithm computes the venn diagrams for each of the following elements;
96+
classes, references, attributes, operations, superTyes, and Enums. VennDiagram is a data structure (implemented as a DTO (Data Transfer Object))
97+
containing a triple such that:
98+
Venn Diagram = (onlyInModel1, intersection, onlyInModel2)
99+
The pseudocode in Pseudocode 2 details the steps to compute the venn diagrams provided
100+
with two arrays of the same types of elements. At first, a hash value of each of
101+
the elements is computed, which is use to index the element. This is followed
102+
by finding pairs of elements that have the maximum similarity score; these
103+
pairs are included in the intersection section of the venn diagram. For the
104+
elements in model 1 that were not paired with any element in model 2; are
105+
included in the set of elements only in model 1, and vice versa.
106+
The algorithm used to compute similarity is detailed in Pseudocode 3.
107+
The ”computeSimilarity” function computes a dot product of the two hash
108+
values. It expects the hash to be a 64 bit binary value. The usage of this
109+
function can be seen in Pseudocode 2. The ”computeHash” function takes
110+
input an element and computes a sum of the hash values of each of its
111+
features. The function ”getHashValue” is ued to compute a 64 bit binary
112+
hash of each individual feature in the element. If the feature is a text-based
113+
feature then the ”hashNGram” function is used to compute the 64 bit binary
114+
hash for that feature value. This technique is inspired from the ”hashNGram”
115+
function proposed by Xiao He. The hashNGram function breaks the
116+
string into bi-grams and for each bi-gram computes a 64 bit binary hash; these
117+
hash values are summed up to get a 64-bit hash value for the feature. We
118+
have introduced a variation to accommodate for classes that are composed of only 1 letter, for example ”public class A ”. We have added an if condition
119+
to check if such is the case, then the hashCode for that letter is returned
120+
instead of computing the bigrams.
121+
122+
### Pseudocode 2
123+
<img src="/get_venn_algo.png" alt="venn"/>
124+
125+
### Pseudocode 3
126+
<img src="/semantic_sim_algo.png" alt="venn"/>
127+
This algorithm defines a class SemanticSimilarity to compute the semantic
128+
similarity between two emfatic files. The process begins by extracting and
129+
tokenizing text from the given code using NLTK, then removes packages,
130+
namespace declaration and comments. Package declerations are removed
131+
because the focus of the tools is to find semantic similarity between class
132+
diagrams; it is not necessary for the two models to have the same package
133+
structure for them to be semantically similar. The algorithm tokenizes the
134+
remaining text and converts it into a list of tokens. Then, it uses TF-IDF
135+
(Term Frequency-Inverse Document Frequency) to calculate the importance
136+
of each word in the documents and obtains word embeddings using pre-
137+
trained Word2Vec vectors from the GoogleNews-vectors-negative300 word
138+
embedding model. We have provided support for 2 models; glove6b50d and
139+
GoogleNews-vectors-negative300 that can be configured from the environ-
140+
ment variable of the api. These embeddings are weighted by the TF-IDF
141+
scores to get a weighted average embedding for each document. Finally, the
142+
cosine similarity between the embeddings of the original and predicted code
143+
files is computed to determine their semantic similarity, which is then re-
144+
turned as a score.

contents/docs/getting-started/installation/index.mdx

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)