def determine_datatype(path):
    """
    Determine if plaintext, tokens or parsed XML
    """
    import os
    from collections import Counter
    exts = []
    if not os.path.isdir(path) and not os.path.isfile(path):
        raise ValueError("Corpus path '%s' doesn't exist." % path)
    singlefile = False
    if os.path.isfile(path):
        singlefile = True
        if '.' in path:
            exts = [os.path.splitext(path)[1]]
        else:
            exts = ['.txt']
    else:
        for root, dirs, fs in os.walk(path):
            for f in fs:
                if '.' in f:
                    ext = os.path.splitext(f)[1]
                    exts.append(ext)
    counted = Counter(exts)
    counted.pop('', None)
    try:
        mc = counted.most_common(1)[0][0]
    except IndexError:
        mc = '.txt'
    lookup = {'.txt': 'plaintext', '.conll': 'conll', '.conllu': 'conll'}
    return lookup.get(mc, 'plaintext'), singlefile
