Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://gitlab.com/mcoavoux/mtgpy-release-findings-2021.git
04 December 2021, 19:36:23 UTC
  • Code
  • Branches (1)
  • Releases (1)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • c9972219cd75049269d26632d2bb79619d661298
    • v1.0
  • a387b78
  • /
  • src
  • /
  • pos_tag_eval.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:02d55de3d9618e144fa78b96589871cd12648308
origin badgedirectory badge Iframe embedding
swh:1:dir:18c8d5ffba1b141866b03a2717f92cafe55d5c89
origin badgerevision badge
swh:1:rev:c9972219cd75049269d26632d2bb79619d661298
origin badgesnapshot badge
swh:1:snp:c3b19ab77fec904d36694903d5dade0c8b1c98fc
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: c9972219cd75049269d26632d2bb79619d661298 authored by mcoavoux on 20 May 2021, 13:04:44 UTC
up readme
Tip revision: c997221
pos_tag_eval.py
import corpus_reader
import subprocess
import sys

def get_wordpos(filename):

    params = ["discodop", "treetransforms", filename, "--inputfmt=discbracket", "--outputfmt=wordpos"]
    result = subprocess.check_output(params)

    result = str(result).split("\\n")

    sentences = []
    for line in result:
        line = line.split()
        word_pos = [tok.rsplit("/", 1) for tok in line]
        sentences.append(word_pos)
    if len(sentences[-1]) == 1 and len(sentences[-1][0]) == 1:
        sentences.pop()
    return sentences

if __name__ == "__main__":
    import argparse
    usage=""" """
    parser = argparse.ArgumentParser(description=usage, formatter_class = argparse.RawTextHelpFormatter)

    parser.add_argument("goldtbk", help="Gold corpus tbk format")
    parser.add_argument("preddiscbracket", help="Pred corpus discbracket format")
    
    args = parser.parse_args()

    CPOS = 3

    gold_corpus = corpus_reader.read_ctbk_corpus(args.goldtbk)

    gold_conll = [corpus_reader.get_conll(t) for t in gold_corpus]

    pred_corpus = get_wordpos(args.preddiscbracket)

    # replacements problems
    paren={"$LRB", "$["}

    assert(len(gold_conll) == len(pred_corpus))

    acc = 0
    tot = 0
    for golds, preds in zip(gold_conll, pred_corpus):
        assert(len(golds) == len(preds))
        
        for gtok, ptok in zip(golds, preds):
            if gtok[1] != ptok[0]:
                sys.stderr.write("Warning: {} {}\n".format(gtok[1], ptok[0]))

            if gtok[CPOS] == ptok[1] or (gtok[CPOS] in paren and ptok[1] in paren):
                acc += 1
            tot += 1
    

    print(round(acc / tot * 100, 1))



Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top