Skip to content

Commit

Permalink
Merge pull request #38 from dkpro/refactoring/37-Upgrade-dependencies
Browse files Browse the repository at this point in the history
#37 - Upgrade dependencies
  • Loading branch information
reckart authored Jul 22, 2024
2 parents 4b118bb + 1eb05fe commit e1a8407
Show file tree
Hide file tree
Showing 48 changed files with 1,029 additions and 862 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "main", "release/**" ]
pull_request:
branches: [ "main", "release/**" ]

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
jdk: [17]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}

- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn --no-transfer-progress -B clean verify --file pom.xml

# Fails with error message - no idea why...
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
14 changes: 10 additions & 4 deletions dkpro-statistics-agreement/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>dkpro-statistics-agreement</artifactId>
Expand All @@ -35,11 +37,15 @@
<distribution>repo</distribution>
</license>
</licenses>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
/**
* Default implementation of the {@link IAgreementMeasure} interface providing computational hooks
* for calculating the observed and the expected agreement. The values for observed and expected
* agreement are combined using Scott's (1955) {@code (A_O - A_E) / (1.0 - A_E)} formula
* (where A_O denotes the observed agreement and A_E denotes the expected agreement. See also
* agreement are combined using Scott's (1955) {@code (A_O - A_E) / (1.0 - A_E)} formula (where A_O
* denotes the observed agreement and A_E denotes the expected agreement. See also
* {@link DisagreementMeasure} for the analogous definition of a measure based on the observed and
* expected disagreement.<br>
* <br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class AnnotationStudy
implements IAnnotationStudy
{
private static final long serialVersionUID = -3596722258510421730L;

protected List<String> raters;
protected Set<Object> categories;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ public class AnnotationUnit
implements IAnnotationUnit
{
private static final long serialVersionUID = 4277733312128063453L;
protected int raterIdx;
protected Object category;

protected final int raterIdx;
protected final Object category;

/**
* Initializes the annotation unit with the given category as the annotation by the rater with
* the specified index.
*/
public AnnotationUnit(int raterIdx, final Object category)
public AnnotationUnit(int aRaterIdx, final Object aCategory)
{
this.raterIdx = raterIdx;
this.category = category;
raterIdx = aRaterIdx;
category = aCategory;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
*/
package org.dkpro.statistics.agreement;

import java.lang.invoke.MethodHandles;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Default implementation of the {@link IAgreementMeasure} interface providing computational hooks
* for calculating the observed and the expected disagreement. The values for observed and expected
* disagreement are combined using Krippendorff's (1980) {@code 1 - (D_O / D_E)} formula
* (where D_O denotes the observed disagreement and D_E denotes the expected disagreement. See also
* disagreement are combined using Krippendorff's (1980) {@code 1 - (D_O / D_E)} formula (where D_O
* denotes the observed disagreement and D_E denotes the expected disagreement. See also
* {@link AgreementMeasure} for the analogous definition of a measure based on the observed and
* expected agreement.<br>
* <br>
Expand All @@ -38,26 +43,31 @@
public abstract class DisagreementMeasure
implements IAgreementMeasure
{
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

/**
* Calculates the inter-rater agreement for the annotation study that was passed to the class
* constructor and the currently assigned distance function.
*
* @throws NullPointerException if the study is null.
* @throws NullPointerException
* if the study is null.
*
* @throws ArithmeticException if the study does not contain any item or the number of raters is
* smaller than 2.
* @throws ArithmeticException
* if the study does not contain any item or the number of raters is smaller than 2.
*/
@Override
public double calculateAgreement()
{
double D_O = calculateObservedDisagreement();
double D_E = calculateExpectedDisagreement();

LOG.trace("Disagreement -- observed: {} -- expected: {}", D_O, D_E);

if (D_O == D_E) {
return 0.0;
}
else {
return 1.0 - (D_O / D_E);
}

return 1.0 - (D_O / D_E);
}

protected abstract double calculateObservedDisagreement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
* @see IAnnotationStudy
* @author Christian M. Meyer
*/
public interface IAnnotationItem extends Serializable
public interface IAnnotationItem
extends Serializable
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface IAnnotationStudy

/** Returns the number of raters participating in this study. */
int getRaterCount();

int findRater(final String name);

// -- Categories --
Expand All @@ -63,7 +63,10 @@ public interface IAnnotationStudy
* Returns true if, and only if, the categories defined by the study yield a dichotomy (i.e.,
* there are exactly two categories).
*/
boolean isDichotomous();
default boolean isDichotomous()
{
return getCategoryCount() == 2;
}

// -- Units --

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public interface IAnnotationUnit
extends Serializable
{
/**
* Returns the index of the rater who coded this unit (in case of a coding study) or defined the
* boundaries of this unit (in case of a unitizing study). The first rater has index 0.
* @return the index of the rater who coded this unit (in case of a coding study) or defined the
* boundaries of this unit (in case of a unitizing study). The first rater has index 0.
*/
public int getRaterIdx();
int getRaterIdx();

/**
* Returns the category assigned to this unit by one of the raters. The category might be null
* if, and only if, the unit represents a missing value (in case of a coding study) or a gap (in
* case of a unitizing study).
* @return the category assigned to this unit by one of the raters. The category might be null
* if, and only if, the unit represents a missing value (in case of a coding study) or a
* gap (in case of a unitizing study).
*/
public Object getCategory();
Object getCategory();
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CodingAnnotationItem
implements ICodingAnnotationItem
{
private static final long serialVersionUID = 3447650373912260846L;

protected List<IAnnotationUnit> units;
protected int nonNullCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CodingAnnotationStudy
implements ICodingAnnotationStudy, Cloneable, Serializable
{
private static final long serialVersionUID = -8242222160334337626L;

protected List<ICodingAnnotationItem> items;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,46 @@
public interface IUnitizingAnnotationUnit
extends IAnnotationUnit, Comparable<IUnitizingAnnotationUnit>
{
/**
* @return the offset of the annotation unit (i.e., the start position of the identified
* segment).
* @deprecated Use {@link #getBegin()}
*/
@Deprecated
default long getOffset()
{
return getBegin();
}

/**
* Returns the offset of the annotation unit (i.e., the start position of the identified
* segment).
* @return the length of the annotation unit (i.e., the difference between the end and start
* position of the identified segment).
*/
public long getOffset();
default long getLength()
{
return getEnd() - getBegin();
}

/**
* Returns the length of the annotation unit (i.e., the difference between the end and start
* position of the identified segment).
* @return the right delimiter of the annotation unit (i.e., the end position of the identified
* segment). The method is a shorthand for {@link #getOffset()} + {@link #getLength()}.
* @deprecated Use {@link #getEnd()}
*/
public long getLength();
@Deprecated
default long getEndOffset()
{
return getEnd();
}

/**
* Returns the right delimiter of the annotation unit (i.e., the end position of the identified
* segment). The method is a shorthand for {@link #getOffset()} + {@link #getLength()}.
* @return the offset of the annotation unit (i.e., the start position of the identified
* segment).
*/
public long getEndOffset();
long getBegin();

/**
* @return the right delimiter of the annotation unit (i.e., the end position of the identified
* segment). The method is a shorthand for {@link #getOffset()} + {@link #getLength()}.
*/
long getEnd();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class UnitizingAnnotationStudy
implements IUnitizingAnnotationStudy, Serializable
{
private static final long serialVersionUID = 5877774485360119115L;

protected Set<IUnitizingAnnotationUnit> units;
protected long begin;
protected long length;
Expand Down Expand Up @@ -129,7 +129,7 @@ public Collection<IUnitizingAnnotationUnit> getUnits()
{
return units;
}

@Override
public long getUnitCount(int raterIdx)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ public class UnitizingAnnotationUnit
implements IUnitizingAnnotationUnit
{
private static final long serialVersionUID = -6716379300031576772L;
protected long offset;
protected long length;

final protected long offset;
final protected long length;

/**
* Initializes the unit with the given offset and length as well as the category assigned to the
* unit by the rater with the specified index. Normally, the method
* {@link UnitizingAnnotationStudy#addUnit(long, long, int, Object)} should be used to define
* the annotation units.
*/
protected UnitizingAnnotationUnit(long offset, long length, int raterIdx, final Object category)
protected UnitizingAnnotationUnit(long aOffset, long aLength, int aRaterIdx,
final Object aCategory)
{
super(raterIdx, category);
this.offset = offset;
this.length = length;
super(aRaterIdx, aCategory);
offset = aOffset;
length = aLength;
}

@Override
Expand All @@ -70,6 +71,16 @@ public long getEndOffset()
return offset + length;
}

public long getBegin()
{
return getOffset();
}

public long getEnd()
{
return getEndOffset();
}

@Override
public int compareTo(final IUnitizingAnnotationUnit that)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected void doPrint(final PrintStream out, final ICodingAnnotationStudy study
out.printf(DIVIDER + DOUBLE_FORMAT, sum);
out.println();
}
/*
/*
public void printPercentage(final PrintStream out, final IItemAnnotationStudy study) {
//TODO: measure length of cats. maybe cut them.
Map<Object, Map<Object, Integer>> coincidence =
Expand Down Expand Up @@ -175,5 +175,5 @@ public void printPercentage(final PrintStream out, final IItemAnnotationStudy st
out.printf(DIVIDER + "%1.3f", sum);
out.println();
}
*/
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* of each combination of categories used by two raters. A contigency table
* is only defined for coding studies with exactly two raters. For the example
* by Krippendorff (1980: p. 133), the implementation displays:
* <pre>
* <pre>
* 0 1 Σ
* 0 5 3 8
* 1 1 1 2
Expand Down
Loading

0 comments on commit e1a8407

Please sign in to comment.