Search in sources :

Example 1 with Log

use of com.robertsanek.util.Log in project core by z1lc.

the class AllNumericalClozeDeletionsHaveHashtagHint method runDQ.

@Override
void runDQ() {
    final Set<Long> NOTE_ID_EXCLUSIONS = Sets.newHashSet(// IEEE floating point
    1413928215505L, // IEEE floating point
    1422640917711L, // RS flip-flop
    1414291348391L, // D-type latch
    1414291902632L, // hex 8-F
    1414293098355L, // intel 4004
    1414300247537L, // log base
    1421332676181L, // java interface
    1423892116563L, // checksum
    1424058032996L, // 23/36 rule
    1471447583333L, // type 1/2 hypervisor
    1543988681948L, // SAE 0W-20
    1506893843355L, // Form ADV part 1/2
    1546907641919L, // Das Keyboard 4
    1547699725186L, // python L[::] subsets
    1547937943437L, // shoe names
    1552805817123L, 1552805757575L, 1552804997297L, // bezos type 1 type 2
    1553373071049L, 1553903551657L, 1552684177180L, 1555695726952L, 1582666228007L, 0L);
    Pattern clozeDigitsNoHint = Pattern.compile("\\{\\{c\\d+::\\d+?}}");
    Set<String> noteIdViolationsList = new HashSet<>();
    allNotes.stream().filter(// Cloze highlight model ID
    note -> note.getModel_id() != 1604800000000L).forEach(note -> {
        Matcher matcher = clozeDigitsNoHint.matcher(note.getFields());
        if (matcher.find() && !NOTE_ID_EXCLUSIONS.contains(note.getId())) {
            noteIdViolationsList.add("nid:" + note.getId());
        }
    });
    if (noteIdViolationsList.size() > 0) {
        dqInformation.warn(this.getClass(), noteIdViolationsList);
        log.warn(String.join(" or ", noteIdViolationsList));
    }
}
Also used : HashSet(java.util.HashSet) Log(com.robertsanek.util.Log) Matcher(java.util.regex.Matcher) Set(java.util.Set) Pattern(java.util.regex.Pattern) Sets(com.google.common.collect.Sets) Logs(com.robertsanek.util.Logs) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) HashSet(java.util.HashSet)

Aggregations

Sets (com.google.common.collect.Sets)1 Log (com.robertsanek.util.Log)1 Logs (com.robertsanek.util.Logs)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1