def getMwes(p): currentSentenceIndex = person.getCurrentSentenceIndex(p) id = getId(p.language, currentSentenceIndex, p.chat_id) sa = SentenceAnnotation.get_by_id(id) if sa: return sa.mwes return None
def removeMwe(p, indexArray): currentSentenceIndex = person.getCurrentSentenceIndex(p) sa = getOrInsertSentenceAnnotation(p.language, currentSentenceIndex, p.chat_id) del sa.mwes[tuple(indexArray)] p.selectedMwes = sa.mwes # mirroring on person # sa.put()
def setEmptyMwes(p): currentSentenceIndex = person.getCurrentSentenceIndex(p) sa = getOrInsertSentenceAnnotation(p.language, currentSentenceIndex, p.chat_id) sa.mwes = {} p.selectedMwes = {} # mirroring on person # sa.put()
def changeConfidenceCurrentMWE(p, confidence): currentSentenceIndex = person.getCurrentSentenceIndex(p) indexTuple = person.getSelectedTokensIndexTuple(p) sa = getOrInsertSentenceAnnotation(p.language, currentSentenceIndex, p.chat_id) sa.mwes[indexTuple]['CONFIDENCE'] = confidence p.selectedMwes = sa.mwes # mirroring on person # sa.put()
def renderSentence(p, escapeMarkDown=True): sentenceNumber = str(person.getCurrentSentenceIndex(p) + 1) totalSentences = sentAnno.totalSentPersonCurrentLang(p) if escapeMarkDown: sentence_flat = util.escapeMarkdown(sentAnno.getCurrentSentenceFlat(p)) else: sentence_flat = sentAnno.getCurrentSentenceFlat(p) text_msg = "Current sentence (" + sentenceNumber + \ '/' + str(totalSentences) + '):\n\n' + \ SECTION_SEPARATOR_BOTTOM + "\n" + \ sentence_flat + "\n" + \ SECTION_SEPARATOR_BOTTOM return text_msg
def appendMwe(p, mweLabel, confidence=DEFAULT_CONFIDENCE): currentSentenceIndex = person.getCurrentSentenceIndex(p) sa = getOrInsertSentenceAnnotation(p.language, currentSentenceIndex, p.chat_id) if not sa.mwes: sa.mwes = {} indexTuple = person.getSelectedTokensIndexTuple(p) if CONFIDENCE_ACTIVE: sa.mwes[indexTuple] = {'CATEGORY': mweLabel, 'CONFIDENCE': confidence} else: sa.mwes[indexTuple] = {'CATEGORY': mweLabel} p.selectedMwes = sa.mwes # mirroring on person # sa.put()
def renderSentenceWithMwesList(p, slashedNumbers=True): sentenceNumber = str(person.getCurrentSentenceIndex(p) + 1) totalSentences = sentAnno.totalSentPersonCurrentLang(p) sentence_flat = util.escapeMarkdown(sentAnno.getCurrentSentenceFlat(p)) text_msg = "Current sentence (" + \ person.getHighlightedString(p, sentenceNumber + '/' + str(totalSentences)) + \ '):\n\n' + \ SECTION_SEPARATOR_BOTTOM + "\n" + \ sentence_flat + "\n" + \ SECTION_SEPARATOR_BOTTOM + '\n\n' currentMwes = p.selectedMwes markDownChar = person.getMarkdownChar(p) if currentMwes == None: text_msg += CANCEL + " You have " + markDownChar + "NOT" + markDownChar + " annotated this sentence." elif currentMwes == {}: text_msg += WRITE + " YOUR ANNOTATION:\n" + EMPTY_BIN + " You marked this sentence with " + \ markDownChar + "NO MWEs" + markDownChar + "." else: mweCount = len(currentMwes) text_msg += WRITE + " YOUR ANNOTATION: " + str(mweCount) + " MWE" + \ ("s:" if mweCount>1 else ":") + "\n" + renderSelectedMwes(p, slashedNumbers) return text_msg
def getCurrentSentenceSplitSpaceToken(p): currentSentenceIndex = person.getCurrentSentenceIndex(p) return SENTENCE_SPLIT_SPACE_TOKENS[p.language][ currentSentenceIndex] #[[tok1,tok2],[tok3,tok4],...]