<commit_before>################################################################################
# NER Highlights
#
# Note that selector and context URNs are apparently the same when
# Domeo creates an annotation but different when our script creates the
# annotation
################################################################################

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFiX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFiX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT *
FROM <http://purl.org/net/nlprepository/changed-ddi-expert1-annotation>
WHERE {
 ?s a oa:Highlight;
   oa:context ?context.

 ?context a oa:SpecificResource;
   oa:hasSource "http://172.16.58.3:8080/AnnoStudy/package-insert-section-114.txt.html";
   oa:hasSelector ?selector.

  ?selector oa:prefix ?prefixText.
  ?selector oa:exact ?exactText.
  ?selector oa:suffix ?suffixText.
}

################################################################################
# DDI NLP
#
# Note: This query groups annotations by exact text and then orders
# them by the annotation URNs. This addresses two issues. The first is
# that Domeo keeps multiple version of an annotation. The second, is
# that Domeo creates a new context for an annotation the first time
# that a user makes a change to the annotations loaded from NLP. For
# example, when a user first edits an NLP annotation and then saves,
# Domeo creates a new 'context' with a new 'selector' but the same
# prefix, exact, and suffix text. This causes a basic query to return
# multiple records per annotation URN - one for each combination of
# context and body data associated with the annotation URN. GROUP BY
# aggregates annotations with exactly the same data making it possible
# to compare the original NLP annotation with teh user's modified
# version. 
#
################################################################################

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dikbD2R:<http://dbmi-icode-01.dbmi.pitt.edu:2020/vocab/resource/>
PREFIX domeo:<http://www.w3.org/ns/domeo#>
PREFIX pav:<http://purl.org/pav/>
PREFIX dailymed:<http://dbmi-icode-01.dbmi.pitt.edu/linkedSPLs/vocab/resource/>

SELECT ?annot ?createdOn ?exactText ?modality ?statementType ?drug1Lab ?drug1Type ?drug1Role ?drug2Lab ?drug2Type ?drug2Role
FROM <http://purl.org/net/nlprepository/ddi-expert2-latest-09182014>
WHERE {

  ?annot a oa:expertstudyAnnotation;
     oa:body ?bn1;
     pav:versionNumber ?version;
     oa:context ?context;
     pav:createdOn ?createdOn.
     
     ?context oa:hasSource "http://dbmi-icode-01.dbmi.pitt.edu:2020/AnnoStudy/package-insert-section-9.txt.html".

  ?context oa:hasSelector ?selector.
        
  ?selector a oa:PrefixSuffixTextSelector;
      oa:exact ?exactText.

  ?bn1 domeo:sets ?statement.

  ?statement a poc:DrugDrugInteractionStatement;
     dikbD2R:modality ?modality;
     dikbD2R:statement ?statementType;
     sio:SIO_000628 ?drugsInvolved.

  ?drugsInvolved a dikbD2R:PK_DDI;
     sio:SIO_000132 ?drug1;
     sio:SIO_000132 ?drug2.FILTER(?drug1 > ?drug2)
 
  ?drug1 rdfs:label ?drug1Lab.
  ?drug1 dailymed:activeMoietyRxCUI ?drug1rxc.
  ?drug1 rdf:type ?drug1Type.
  ?drug1 sio:SIO_000228 ?drug1Role.

  ?drug2 rdfs:label ?drug2Lab.
  ?drug2 dailymed:activeMoietyRxCUI ?drug2rxc.
  ?drug2 rdf:type ?drug2Type.
  ?drug2 sio:SIO_000228 ?drug2Role.
}    
GROUP BY ?exactText
ORDER BY DESC(?annot)


################################################################################
# DDI NLP
# add filter to get all pre loaded NLP annotations
################################################################################

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dikbD2R:<http://dbmi-icode-01.dbmi.pitt.edu:2020/vocab/resource/>
PREFIX domeo:<http://www.w3.org/ns/domeo#>
PREFIX pav:<http://purl.org/pav/>
PREFIX dailymed:<http://dbmi-icode-01.dbmi.pitt.edu/linkedSPLs/vocab/resource/>

SELECT ?annot ?source ?exactText ?modality ?statementType ?drug1Lab ?drug1Type ?drug1Role ?drug2Lab ?drug2Type ?drug2Role
<commit_msg>revise ddis query to filter out preload NLPs<commit_after>################################################################################
# NER Highlights
#
# Note that selector and context URNs are apparently the same when
# Domeo creates an annotation but different when our script creates the
# annotation
################################################################################

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFiX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFiX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT *
FROM <http://purl.org/net/nlprepository/changed-ddi-expert1-annotation>
WHERE {
 ?s a oa:Highlight;
   oa:context ?context.

 ?context a oa:SpecificResource;
   oa:hasSource "http://172.16.58.3:8080/AnnoStudy/package-insert-section-114.txt.html";
   oa:hasSelector ?selector.

  ?selector oa:prefix ?prefixText.
  ?selector oa:exact ?exactText.
  ?selector oa:suffix ?suffixText.
}

################################################################################
# DDI NLP
#
# Note: This query groups annotations by exact text and then orders
# them by the annotation URNs. This addresses two issues. The first is
# that Domeo keeps multiple version of an annotation. The second, is
# that Domeo creates a new context for an annotation the first time
# that a user makes a change to the annotations loaded from NLP. For
# example, when a user first edits an NLP annotation and then saves,
# Domeo creates a new 'context' with a new 'selector' but the same
# prefix, exact, and suffix text. This causes a basic query to return
# multiple records per annotation URN - one for each combination of
# context and body data associated with the annotation URN. GROUP BY
# aggregates annotations with exactly the same data making it possible
# to compare the original NLP annotation with teh user's modified
# version. 
#
################################################################################

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dikbD2R:<http://dbmi-icode-01.dbmi.pitt.edu:2020/vocab/resource/>
PREFIX domeo:<http://www.w3.org/ns/domeo#>
PREFIX pav:<http://purl.org/pav/>
PREFIX dailymed:<http://dbmi-icode-01.dbmi.pitt.edu/linkedSPLs/vocab/resource/>

SELECT ?annot ?createdOn ?exactText ?modality ?statementType ?drug1Lab ?drug1Type ?drug1Role ?drug2Lab ?drug2Type ?drug2Role
FROM <http://purl.org/net/nlprepository/ddi-expert2-latest-09182014>
WHERE {

  ?annot a oa:expertstudyAnnotation;
     oa:body ?bn1;
     pav:versionNumber ?version;
     oa:context ?context;
     pav:createdOn ?createdOn.
     
     ?context oa:hasSource "http://dbmi-icode-01.dbmi.pitt.edu:2020/AnnoStudy/package-insert-section-9.txt.html".

  ?context oa:hasSelector ?selector.
        
  ?selector a oa:PrefixSuffixTextSelector;
      oa:exact ?exactText.

  ?bn1 domeo:sets ?statement.

  ?statement a poc:DrugDrugInteractionStatement;
     dikbD2R:modality ?modality;
     dikbD2R:statement ?statementType;
     sio:SIO_000628 ?drugsInvolved.

  ?drugsInvolved a dikbD2R:PK_DDI;
     sio:SIO_000132 ?drug1;
     sio:SIO_000132 ?drug2.FILTER(?drug1 > ?drug2)
 
  ?drug1 rdfs:label ?drug1Lab.
  ?drug1 dailymed:activeMoietyRxCUI ?drug1rxc.
  ?drug1 rdf:type ?drug1Type.
  ?drug1 sio:SIO_000228 ?drug1Role.

  ?drug2 rdfs:label ?drug2Lab.
  ?drug2 dailymed:activeMoietyRxCUI ?drug2rxc.
  ?drug2 rdf:type ?drug2Type.
  ?drug2 sio:SIO_000228 ?drug2Role.FILTER(?drug1Role != ?drug2Role).
}    
GROUP BY ?exactText
ORDER BY DESC(?annot)


################################################################################
# DDI NLP
# add filter to get all pre loaded NLP annotations
################################################################################

PREFIX oa:<http://www.w3.org/ns/oa#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX poc: <http://purl.org/net/nlprepository/spl-pharmgx-annotation-poc#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dikbD2R:<http://dbmi-icode-01.dbmi.pitt.edu:2020/vocab/resource/>
PREFIX domeo:<http://www.w3.org/ns/domeo#>
PREFIX pav:<http://purl.org/pav/>
PREFIX dailymed:<http://dbmi-icode-01.dbmi.pitt.edu/linkedSPLs/vocab/resource/>

SELECT ?annot ?source ?exactText ?modality ?statementType ?drug1Lab ?drug1Type ?drug1Role ?drug2Lab ?drug2Type ?drug2Role

{'fraction_non_alphanumeric': 0.2169711129991504, 'fraction_numerical': 0.03228547153780799, 'mean_word_length': 4.963901203293224, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 20, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6610258', 'n_tokens_mistral': 3521, 'n_tokens_neox': 3170, 'n_words': 728}