import codecs


def getLines(filename, measureByGap):
    """
    Number of sentences in the file, measured either in lines, or by empty "gap" lines
    """
    numSentences = 0
    f = codecs.open(filename, "rt", "utf-8")
    for line in f:
        if measureByGap:
            if line.strip() == "":
                numSentences += 1
        else:
            numSentences += 1
    f.close()
    return numSentences