-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
The MIT License (MIT) | ||
Copyright (c) 2017-2018 Yegor Bugayenko | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
--> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> | ||
<xsl:param name="ctors" select="0"/> | ||
<xsl:template match="skeleton"> | ||
<metric> | ||
<xsl:apply-templates select="@*"/> | ||
<title>C3</title> | ||
<description> | ||
<xsl:text><![CDATA[ | ||
C3(c) = ACMS(c) if ACMS(c) > 0 else 0; where c is a class | ||
ACSM(c) = average CSM(c) for all method pairs in c (skip identity | ||
pairs, i.e. a method pairing with itself) | ||
CSM(m1, m2) = cosine between LSI(m1) and LSI(m2) | ||
LSI is a vector, defined as: | ||
1) For each function, collect all unique words from variable | ||
names and comments (split variable names such as `myDatabaseBook` into | ||
words `my`, `database`, and `book. | ||
2) Extract frequency information and build co-occurrence matrix. | ||
3) Reduce matrix with SVD. | ||
More info on LSI: https://en.wikipedia.org/wiki/Latent_semantic_analysis#Latent_semantic_indexing | ||
The original paper is at /papers/marcus05.pdf. | ||
]]></xsl:text> | ||
</description> | ||
<xsl:apply-templates select="node()"/> | ||
</metric> | ||
</xsl:template> | ||
<xsl:template match="class"> | ||
<xsl:variable name="methods" select="methods/method[($ctors=0 and @ctor='false') or $ctors=1]"/> | ||
<xsl:variable name="possible_relations"> | ||
<xsl:for-each select="$methods"> | ||
<xsl:variable name="i" select="position()"/> | ||
<xsl:variable name="left" select="."/> | ||
<xsl:for-each select="$methods"> | ||
<xsl:if test="position() > $i"> | ||
<xsl:variable name="right" select="."/> | ||
</xsl:if> | ||
</xsl:for-each> | ||
</xsl:for-each> | ||
</xsl:variable> | ||
<!-- | ||
@todo #64:30min Implement the C3 method according to the description above. | ||
The variable names and comments have to be extracted into a set of words. | ||
JPeek core will have to provide all comments for each method so words | ||
can be extracted and LSI calculated for each method. | ||
--> | ||
</xsl:template> | ||
<xsl:template match="node()|@*"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="node()|@*"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |
fff617e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
64-b6d7d67d
discovered insrc/main/resources/org/jpeek/metrics/C3.xsl
and submitted as #175. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, butwe discovered it only now.