Exemplo n.º 1
0
def lookup(args):
    """
    Looks up a single gloss from the commandline.

    concepticon lookup <gloss1 gloss2 ... glossN>
    """
    api = Concepticon()
    found = api.lookup(args.args,
                       language=args.language,
                       full_search=args.full_search,
                       similarity_level=args.similarity)
    with UnicodeWriter(None, delimiter='\t') as writer:
        writer.writerow(
            ['GLOSS', 'CONCEPTICON_ID', 'CONCEPTICON_GLOSS', 'SIMILARITY'])
        for f in found:
            writer.writerow(f)
        print(writer.read().decode('utf-8'))
Exemplo n.º 2
0
def notlinked(args):
    api = Concepticon(args.repos)
    i = 0
    for _, cl in sorted(api.conceptlists.items(), key=lambda p: p[0]):
        for concept in sorted(
                cl.concepts.values(),
                key=lambda p: int(re.match('([0-9]+)', p.number).groups()[0])):
            if not concept.concepticon_id:
                candidates = [
                    c for c in list(api.lookup([concept.label]))[0] if c[3] < 3
                ]
                if candidates:
                    candidate = sorted(candidates, key=lambda c: c[3])[0]
                    candidate = "{0} [{1}]".format(candidate[2], candidate[1])
                    i += 1
                    print("{0} {1.id}: {1.label}: {2}".format(
                        i, concept, candidate))
Exemplo n.º 3
0
def lookup(args):
    """
    Look up the specified glosses in Concepticon.

    Examples
    --------
    $ concepticon lookup gloss1 gloss2 gloss3 ...
    """
    api = Concepticon()
    found = api.lookup(
        args.args,
        language=args.language,
        full_search=args.full_search,
        similarity_level=args.similarity)

    with UnicodeWriter(None) as writer:
        writer.writerow(['GLOSS', 'CONCEPTICON_ID', 'CONCEPTICON_GLOSS', 'SIMILARITY'])
        for matches in found:
            for m in matches:
                writer.writerow(m)
        print(writer.read().decode('utf-8'))