Skip to content
Snippets Groups Projects
Commit b4c71d98 authored by kunyin2's avatar kunyin2
Browse files

project source code

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #194498 canceled
Showing
with 1173 additions and 0 deletions
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 140
tab_width = 4
# Maven stuff
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
# Eclipse stuff
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
.classpath
.project
# MacOS stuff
*.DS_Store
# IntelliJ stuff
.idea
*.iml
# n2c2 stuff
*.xml
# Models
models/*
.Rproj.user
language: java
matrix:
include:
- jdk: openjdk8
- jdk: openjdk11
- jdk: openjdk14
addons:
apt:
packages:
- python3
script: mvn test -B
after_success:
- mvn clean test jacoco:report coveralls:report
notifications:
email:
on_success: change
on_failure: always
slack:
rooms:
secure: BPqf1rE/88+zWAj8ZRvfEEa+wI/dr9iszkCHzGs262KXbCdQd9nt5e4ucmv3ATUIVeiSkNNflxakFeUhwEGkVfUt5MCT929uajcJCudB6X6fBklfEYghX0QqgIHWpdCknsQIh7AYlxMrPfgzVQ7J57pCiOJKplmKWgeazEu+ArpMpKm1foyuqf4raqZXdtdRxtZQJ254x8rTyUx0OkuOkkq+Jf8q1g4xBKpHJA2cm9L/fMcUKDvzH4A8FDvesQSAUMjHmgNPLkAWeVEcjwjME/I+pyxeSWqI28jBwzxtZBN0WImtsji4t6rev4z4H6VOFNVuJyuNXawEb2G8QK7B5XbbcPJa4Y1qMC5fiBvcqYBdbD/0AxHCYdil7BDRAI7lNUljBSPAf0HlV3oiJqMjdCiDAJfMMPO97MBsgRtIVqaH2+5T8VRXJX9wah2XRv/B+dCAKuc2xhlmo/MH1SEFHt/fVaHfCf4bX19dsy+bKu+ioDapSdo1cXHq1Bn1jHVLyLOjmCHOAfxVwUMY4ZMdgisFe1fvdMzdEGvwaRS3wKHLuXbiuPrxkY2m5Gb9iTYH2fPgORj7+i49ClPmDEzehsach/6Ymq+cVxqo0GjKIjy9++rmBd50vGDBrHmiPbZ2fZxs+uiIEp1kFQXe9CtCf4In/2HuYCFwxwtzETJWrx0=
on_success: change
on_failure: always
on_pull_requests: false
LICENSE 0 → 100644
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Criterion Baseline RBC SVM SELF-LR PRE-LR SELF-LSTM PRE-LSTM
\ No newline at end of file
Criterion Baseline RBC SVM SELF-LR PRE-LR SELF-LSTM PRE-LSTM
library(dplyr)
library(tidyr)
library(ggplot2)
library(ggpubr)
old_wd <- getwd()
setwd("R")
collect_data <- function(file) {
data <- read.delim(file)
# We reorganize data into rows since it was created manually.
# May not be necessary if generated by a script.
data <- data %>% gather(key="method", value="value", factor_key=TRUE, -Criterion)
# Set user friendly names.
levels(data$method) <- gsub("([A-Z]{3,4}).([A-Z]{2,4})", "\\1-\\2", levels(data$method))
return(data)
}
plot_data <- function(data, title) {
g <- ggplot(data=data, aes(x=Criterion, y=value, fill=method)) +
geom_bar(stat="identity", position=position_dodge2(reverse=TRUE), color="black", size=0.25) +
coord_flip() +
scale_x_discrete(limits = rev(levels(data$Criterion))) +
scale_y_continuous(breaks=seq(0,1,0.1), limits=c(0,1)) +
ylab(title) +
scale_fill_brewer(palette="Set2") +
theme_linedraw() +
theme(legend.title=element_blank())
return(g)
}
f1_data <- collect_data("f1.tsv")
f1_plot <- plot_data(f1_data, "F1")
ggexport(f1_plot, filename="f1.pdf", height=10)
accuracy_data <- collect_data("accuracy.tsv")
accuracy_plot <- plot_data(accuracy_data, "Accuracy")
ggexport(accuracy_plot, filename="accuracy.pdf", height=10)
setwd(old_wd)
\ No newline at end of file
library(stats)
data <- read.csv("false-analysis.csv")
# Comparisons to baseline
for (i in 3:ncol(data)) {
htest <- mcnemar.test(data[,2], data[,i], correct=FALSE)
print(htest)
}
# Pre x Self
mcnemar.test(data[,5], data[,6], correct=FALSE)
mcnemar.test(data[,7], data[,8], correct=FALSE)
\ No newline at end of file
# National NLP Clinical Challenges (n2c2)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/61f8f04b341a482f95b9a38073575860)](https://app.codacy.com/app/michelole/n2c2?utm_source=github.com&utm_medium=referral&utm_content=bst-mug/n2c2&utm_campaign=badger)
[![Build Status](https://travis-ci.org/bst-mug/n2c2.svg?branch=master)](https://travis-ci.org/bst-mug/n2c2)
[![Coverage Status](https://coveralls.io/repos/github/bst-mug/n2c2/badge.svg?branch=master)](https://coveralls.io/github/bst-mug/n2c2?branch=master)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
A repository containing support code and resources developed at the [Institute for Medical Informatics, Statistics and Documentation at the Medical University of Graz (Austria)](https://www.medunigraz.at/imi/en/) for participation at the [2018 n2c2 Shared-Task Track 1](https://n2c2.dbmi.hms.harvard.edu/) organized by the Department of Biomedical Informatics at the Harvard Medical School.
## Citing
If you use data or code in your work, please cite our [JAMIA paper](https://academic.oup.com/jamia/advance-article/doi/10.1093/jamia/ocz149/5568257):
```
@article{oleynik2019evaluating,
title={Evaluating shallow and deep learning strategies for the 2018 n2c2 shared-task on clinical text classification},
author={Michel Oleynik and Amila Kugic and Zdenko Kasáč and Markus Kreuzthaler},
journal={Journal of the American Medical Informatics Association},
publisher={Oxford University Press},
year={2019}
}
```
Also of interest:
- Our [n2c2 presentation slides](https://www.medunigraz.at/imi/de/n2c2.Presentation_V6.pdf)
## Code Dependencies
- JDK8+
- python3 (to run official evaluation scripts)
- make (to compile fastText)
- gcc/clang (to compile fastText)
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
-->
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format"
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message"
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="max" value="140"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
<module name="EmptyBlock">
<property name="option" value="TEXT"/>
<property name="tokens"
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces"/>
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="id" value="RightCurlySame"/>
<property name="tokens"
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
LITERAL_DO"/>
</module>
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyLambdas" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/>
<module name="MissingSwitchDefault"/>
<module name="FallThrough"/>
<module name="UpperEll"/>
<module name="ModifierOrder"/>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapDot"/>
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapComma"/>
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 -->
<property name="id" value="SeparatorWrapEllipsis"/>
<property name="tokens" value="ELLIPSIS"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
<property name="id" value="SeparatorWrapArrayDeclarator"/>
<property name="tokens" value="ARRAY_DECLARATOR"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapMethodRef"/>
<property name="tokens" value="METHOD_REF"/>
<property name="option" value="nl"/>
</module>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LambdaParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="CatchParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="4"/>
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder">
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
</module>
<module name="MethodParamPad"/>
<module name="NoWhitespaceBefore">
<property name="tokens"
value="COMMA, SEMI, POST_INC, POST_DEC, DOT, ELLIPSIS, METHOD_REF"/>
<property name="allowLineBreaks" value="true"/>
</module>
<module name="ParenPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens"
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
</module>
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationMostCases"/>
<property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
</module>
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationVariables"/>
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="InvalidJavadocPosition"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments"
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph"/>
<module name="AtclauseOrder">
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
<property name="target"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc">
<property name="ignoreInlineTags" value="false"/>
</module>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
</module>
</module>
</module>
# SVM cost values per class
svm.cost.makes_decisions=1
svm.cost.hba1c=1
svm.cost.asp_for_mi=1
svm.cost.alcohol_abuse=1
svm.cost.advanced_cad=1
svm.cost.creatinine=1
svm.cost.english=1
svm.cost.mi_6mos=1
svm.cost.drug_abuse=1
svm.cost.major_diabetes=1
svm.cost.keto_1yr=1
svm.cost.abdominal=1
svm.cost.dietsupp_2mos=1
nn.samplesTraining=data/train/
nn.models=models/
nn.samplesTrainingBDT=Z:/n2c2/data/models/samplesTrainingBDT
nn.samplesTestBDT=Z:/n2c2/data/models/samplesTestBDT/
nn.samplesPredictedBDT=out/
\ No newline at end of file
pom.xml 0 → 100644
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>at.medunigraz.imi.bst</groupId>
<artifactId>n2c2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>n2c2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- BEGIN added for deeplearning4j -->
<!-- .............................. -->
<!-- Generic properties -->
<java.version>1.8</java.version>
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> -->
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Change the nd4j.backend property to nd4j-cuda-7.5-platform or nd4j-cuda-8.0-platform
to use CUDA GPUs -->
<nd4j.backend>nd4j-native-platform</nd4j.backend>
<!-- <nd4j.backend>nd4j-cuda-8.0-platform</nd4j.backend> -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shadedClassifier>bin</shadedClassifier>
<nd4j.version>0.9.1</nd4j.version>
<dl4j.version>0.9.1</dl4j.version>
<datavec.version>0.9.1</datavec.version>
<arbiter.version>0.9.1</arbiter.version>
<rl4j.version>0.9.1</rl4j.version>
<!-- For Spark examples: change the _1 to _2 to switch between Spark 1
and Spark 2 -->
<dl4j.spark.version>0.9.1_spark_1</dl4j.spark.version>
<datavec.spark.version>0.9.1_spark_1</datavec.spark.version>
<!-- Scala binary version: DL4J's Spark and UI functionality are released
with both Scala 2.10 and 2.11 support -->
<scala.binary.version>2.11</scala.binary.version>
<logback.version>1.1.7</logback.version>
<jfreechart.version>1.0.13</jfreechart.version>
<jcommon.version>1.0.23</jcommon.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven.minimum.version>3.3.1</maven.minimum.version>
<!--<javafx.version>2.2.3</javafx.version>-->
<!--<javafx.runtime.lib.jar>${env.JAVAFX_HOME}/jfxrt.jar</javafx.runtime.lib.jar>-->
<aws.sdk.version>1.11.109</aws.sdk.version>
<jackson.version>2.6.6</jackson.version>
<scala.plugin.version>3.2.2</scala.plugin.version>
<!-- END added for deeplearning4j -->
<!-- ............................ -->
</properties>
<build>
<filters>
<filter>n2c2.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<!-- fastText -->
<mkdir dir="${project.build.directory}/lib" />
<get
src="https://github.com/facebookresearch/fastText/archive/v0.2.0.zip"
dest="${project.build.directory}/lib/fastText-0.2.0.zip"
verbose="false" usetimestamp="true"/>
<unzip
src="${project.build.directory}/lib/fastText-0.2.0.zip"
dest="${project.build.directory}/lib/" />
<exec executable="make" failonerror="true"
dir="${project.build.directory}/lib/fastText-0.2.0/"/>
<move file="${project.build.directory}/lib/fastText-0.2.0/fasttext"
tofile="${project.build.directory}/lib/fasttext"/>
<!-- Evaluation script -->
<get
src="https://raw.githubusercontent.com/filannim/2018_n2c2_evaluation_scripts/master/track1_eval.py"
dest="${project.build.directory}/track1_eval.py"
verbose="false" usetimestamp="true"/>
<!-- Sample file -->
<get
src="https://n2c2.dbmi.hms.harvard.edu/files/n2c2_sample_file_annotations.zip"
dest="${project.build.directory}/n2c2_sample_file_annotations.zip"
verbose="false" usetimestamp="true" />
<unzip
src="${project.build.directory}/n2c2_sample_file_annotations.zip"
dest="${project.build.directory}" />
<copy
file="${project.build.directory}/n2c2_sample_file_annotations/sample.xml"
tofile="${basedir}/src/test/resources/gold-standard/sample.xml" />
<copy
file="${project.build.directory}/n2c2_sample_file_annotations/sample.xml"
tofile="${basedir}/src/test/resources/results/sample.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!--<plugin>-->
<!--<groupId>org.codehaus.mojo</groupId>-->
<!--<artifactId>exec-maven-plugin</artifactId>-->
<!--<version>1.6.0</version>-->
<!--<configuration>-->
<!--<mainClass>at.medunigraz.imi.bst.n2c2.SVMClassifierRunner/mainClass>-->
<!--</configuration>-->
<!--</plugin>-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
<!-- BEGIN added for deeplearning4j -->
<!-- .............................. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>${shadedClassifier}</shadedClassifierName>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>org/datanucleus/**</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-compiler-plugin</artifactId> -->
<!-- <version>3.5.1</version> -->
<!-- <configuration> -->
<!-- <source>${java.version}</source> -->
<!-- <target>${java.version}</target> -->
<!-- </configuration> -->
<!-- </plugin> -->
<!-- END added for deeplearning4j -->
<!-- ............................ -->
</plugins>
</build>
<!-- BEGIN added for deeplearning4j -->
<!-- .............................. -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>${nd4j.version}</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-7.5-platform</artifactId>
<version>${nd4j.version}</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-8.0-platform</artifactId>
<version>${nd4j.version}</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-cuda-9.0-platform</artifactId>
<version>${nd4j.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<!-- END added for deeplearning4j -->
<!-- ............................ -->
<dependencies>
<!-- BEGIN added for deeplearning4j -->
<!-- .............................. -->
<!-- ND4J backend. You need one in every DL4J project. Normally define
artifactId as either "nd4j-native-platform" or "nd4j-cuda-7.5-platform" -->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>${nd4j.backend}</artifactId>
</dependency>
<!-- Core DL4J functionality -->
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>${dl4j.version}</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-nlp</artifactId>
<version>${dl4j.version}</version>
</dependency>
<!-- deeplearning4j-ui is used for HistogramIterationListener + visualization:
see http://deeplearning4j.org/visualization -->
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-ui_${scala.binary.version}</artifactId>
<version>${dl4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-analyzers-common -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>7.5.0</version>
</dependency>
<!-- END added for deeplearning4j -->
<!-- ............................ -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka</groupId>
<artifactId>weka-stable</artifactId>
<version>3.8.2</version>
</dependency>
<dependency>
<groupId>nz.ac.waikato.cms.weka</groupId>
<artifactId>LibSVM</artifactId>
<version>1.0.10</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
<scope>provided</scope>
</dependency>
<!-- JDK10+ https://github.com/deeplearning4j/deeplearning4j/issues/5804#issuecomment-443487090-->
<dependency>
<groupId>net.jodah</groupId>
<artifactId>typetools</artifactId>
<version>0.5.0</version>
</dependency>
<!-- May be used for Weka stemmer. Conflicts with Lucene dependencies -->
<!--<dependency>-->
<!--<groupId>com.github.rholder</groupId>-->
<!--<artifactId>snowball-stemmer</artifactId>-->
<!--<version>1.3.0.581.1</version>-->
<!--</dependency>-->
</dependencies>
</project>
#!/bin/sh
# First parameter is the embeddings model, either:
# a) `n2c2-fasttext.bin` (manually generated by `train_embeddings.sh`);
# b) `BioWordVec_PubMed_MIMICIII_d200.bin` (downloaded from https://github.com/ncbi-nlp/BioSentVec)
# BioWordVec_PubMed_MIMICIII_d200, this is the link to download: https://ftp.ncbi.nlm.nih.gov/pub/lu/Suppl/BioSentVec/BioWordVec_PubMed_MIMICIII_d200.bin
# `vocab.txt` should be first generated by `VocabularyDumper.java`
# fasttext print-word-vectors n2c2-fasttext.bin < vocab.txt > vectors.tsv
fasttext print-word-vectors BioWordVec_PubMed_MIMICIII_d200.bin < vocab.txt > vectors.tsv
# The `.vec` file loaded by deeplearning4j requires an extra line with the input dimensions.
LINES=27875
DIM=200
echo "$LINES $DIM" | cat - vectors.tsv > vectors.vec
\ No newline at end of file
#!/bin/sh
# Parameters follows https://github.com/ncbi-nlp/BioSentVec/blob/master/src/train_biowordvec.sh
# `sentences.txt` should be first generated by `SentenceDumper.java`
fasttext skipgram -input sentences.txt -output n2c2-fasttext -dim 200 -t 0.001 -minCount 0 -neg 10 -wordNgrams 6 -ws 20
\ No newline at end of file
package at.medunigraz.imi.bst.n2c2;
import at.medunigraz.imi.bst.n2c2.classifier.factory.ClassifierFactory;
import at.medunigraz.imi.bst.n2c2.classifier.factory.FactoryProvider;
import at.medunigraz.imi.bst.n2c2.evaluator.BasicEvaluator;
import at.medunigraz.imi.bst.n2c2.evaluator.Evaluator;
import at.medunigraz.imi.bst.n2c2.evaluator.OfficialEvaluator;
import at.medunigraz.imi.bst.n2c2.model.Patient;
import at.medunigraz.imi.bst.n2c2.model.metrics.Metrics;
import at.medunigraz.imi.bst.n2c2.stats.CSVStatsWriter;
import at.medunigraz.imi.bst.n2c2.stats.StatsWriter;
import at.medunigraz.imi.bst.n2c2.util.DatasetUtil;
import at.medunigraz.imi.bst.n2c2.validation.TestValidator;
import at.medunigraz.imi.bst.n2c2.validation.Validator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
public class ClassifierRunner {
private static final Logger LOG = LogManager.getLogger();
private static final ClassifierFactory[] CLASSIFIERS = new ClassifierFactory[]{
FactoryProvider.getMajorityFactory(),
FactoryProvider.getRBCFactory(),
FactoryProvider.getSVMFactory(),
FactoryProvider.getSelfTrainedPerceptronFactory(),
// FactoryProvider.getPreTrainedPerceptronFactory(),
FactoryProvider.getLSTMSelfTrainedFactory()
// FactoryProvider.getLSTMPreTrainedFactory()
};
public static void main(String[] args) throws IOException {
final File trainFolder = new File("data/train");
final File testFolder = new File("data/test");
final File statsFolder = new File("stats");
List<Patient> trainPatients = DatasetUtil.loadFromFolder(trainFolder);
List<Patient> testPatients = DatasetUtil.loadFromFolder(testFolder);
Collections.sort(testPatients);
Evaluator officialEvaluator = new OfficialEvaluator(); // n2c2 official metrics
Evaluator basicEvaluator = new BasicEvaluator(); // accuracy and fp/fn metrics
for (ClassifierFactory factory : CLASSIFIERS) {
String name = factory.toString();
LOG.info("Running {}...", name);
System.out.println("Running {}..." + name);
Validator officialValidator = new TestValidator(trainPatients, testPatients, factory, officialEvaluator);
Validator basicValidator = new TestValidator(trainPatients, testPatients, factory, basicEvaluator);
Metrics officialMetrics = officialValidator.validate();
Metrics basicMetrics = basicValidator.validate();
// run FastTextFacade:
/*
] /Users/yunfei/Documents/fastText-0.9.2/fasttext supervised -input /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/fasttext/train.txt -output /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/fasttext/model -thread 1 -epoch 100 -lr 0.50 -dim 200 -pretrainedVectors /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/target/classes/at/medunigraz/imi/bst/n2c2/classifier/self-trained-vectors.vec
16:39:48 DEBUG [FastTextFacade ] /Users/yunfei/Documents/fastText-0.9.2/fasttext predict /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/fasttext/model.bin /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/fasttext/test.txt
16:39:50 DEBUG [FastTextFacade ] /Users/yunfei/Documents/fastText-0.9.2/fasttext supervised -input /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/fasttext/train.txt -output /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/fasttext/model -thread 1 -epoch 100 -lr 0.50 -dim 200 -pretrainedVectors /Users/yunfei/Desktop/uiuc/598-deep-learning/project/n2c2/target/classes/at/medunigraz/imi/bst/n2c2/classifier/self-trained-vectors.vec
*/
writeAndClose(officialMetrics, new File(statsFolder, name + "-official.csv"));
writeAndClose(basicMetrics, new File(statsFolder, name + "-basic.csv"));
}
}
private static void writeAndClose(Metrics metrics, File file) throws IOException {
StatsWriter csvWriter = new CSVStatsWriter(file);
csvWriter.write(metrics);
csvWriter.close();
}
}
package at.medunigraz.imi.bst.n2c2.classifier;
import at.medunigraz.imi.bst.n2c2.model.Criterion;
import at.medunigraz.imi.bst.n2c2.model.Eligibility;
import at.medunigraz.imi.bst.n2c2.model.Patient;
import java.util.List;
public interface Classifier {
void train(List<Patient> examples);
Eligibility predict(Patient p, Criterion c);
List<Patient> predict(List<Patient> patientList);
}
package at.medunigraz.imi.bst.n2c2.classifier;
import at.medunigraz.imi.bst.n2c2.model.Criterion;
import at.medunigraz.imi.bst.n2c2.model.Eligibility;
import at.medunigraz.imi.bst.n2c2.model.Patient;
import java.util.List;
public abstract class CriterionBasedClassifier implements Classifier {
protected Criterion criterion;
public CriterionBasedClassifier(Criterion c) {
this.criterion = c;
}
@Override
public List<Patient> predict(List<Patient> patientList) {
patientList.forEach(p -> p.withCriterion(criterion, predict(p)));
return patientList;
}
@Override
public Eligibility predict(Patient p, Criterion c) {
if (!c.equals(criterion)) {
throw new UnsupportedOperationException("Criterion must be consistent with constructor!");
}
return predict(p);
}
public abstract Eligibility predict(Patient p);
@Override
public String toString() {
return getClass().getSimpleName();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment