Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 12, 2018
2 parents 7033094 + b08d0c6 commit fff617e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
Binary file added papers/marcus05.pdf
Binary file not shown.
77 changes: 77 additions & 0 deletions src/main/resources/org/jpeek/metrics/C3.xsl
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() &gt; $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>

1 comment on commit fff617e

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on fff617e Feb 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 64-b6d7d67d discovered in src/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, but
we discovered it only now.

Please sign in to comment.