예제 #1
0
                count = 0

            elem.set("count", str(count))
            
    # Finally, add totals, per category and overall,  to the doc root
    # Note that all words _not_ in Cornetto are not included in these totals 
    totals["all"] = sum(totals.values())
    
    for cat, count in totals.items():
        parser.root.set("count-total-%s" % cat, str(count))
        
    return ElementTree(parser.root)


parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("cdb_lu", type=file,
                    help="xml file containing the lexical units")

parser.add_argument("word_counts", type=file,
                    help="tabular file containing the word counts")

args = parser.parse_args()


counts, totals = read_counts(args.word_counts)

etree = add_count_attrib(counts, totals, args.cdb_lu)
    
예제 #2
0
            del elem.attrib[attr]


def remove_elem(elem, parent):
    try:
        parent.remove(elem)
    except AttributeError:
        # parent is None because this is the root elem,
        # which cannot be removed
        pass


strip_methods = dict(default=strip_elem_default, minimal=strip_elem_minimal)

parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("file",
                    help="xml file specifying lexical units or synsets")

parser.add_argument("--method",
                    "-m",
                    choices=["default", "minimal"],
                    default="default",
                    help="method of stripping")

args = parser.parse_args()

strip(args.file, strip_methods[args.method])
예제 #3
0

__author__ = 'Erwin Marsi <*****@*****.**>'

__version__ = '0.9'

from sys import exit
from cornetto.argparse import ArgumentParser, RawDescriptionHelpFormatter, SUPPRESS
from cornetto.server import start_server

from daeso_nl.cornetto.server import DaesoCornetProxy, DEFAULT_HOST, DEFAULT_PORT



parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("-H", "--host", 
                    default="%s:%d" % (DEFAULT_HOST, DEFAULT_PORT),
                    metavar="HOST[:PORT]",
                    help="name or IP address of host " +
                    "(default is '%s') " % DEFAULT_HOST +
                    "optionally followed by a port number "
                    "(default is %d)" % DEFAULT_PORT)

parser.add_argument('-l', '--log', 
                    action='store_true', 
                    help="log requests")

parser.add_argument("-m", "--max-depth", 
예제 #4
0
            "target",
            "relation_name",
        ):
            del elem.attrib[attr]


def remove_elem(elem, parent):
    try:
        parent.remove(elem)
    except AttributeError:
        # parent is None because this is the root elem,
        # which cannot be removed
        pass


strip_methods = dict(default=strip_elem_default, minimal=strip_elem_minimal)


parser = ArgumentParser(
    description=__doc__, version="%(prog)s version " + __version__, formatter_class=RawDescriptionHelpFormatter
)

parser.add_argument("file", help="xml file specifying lexical units or synsets")

parser.add_argument("--method", "-m", choices=["default", "minimal"], default="default", help="method of stripping")

args = parser.parse_args()


strip(args.file, strip_methods[args.method])
예제 #5
0
import sys

try:
    import cornetto
except ImportError, inst:
    print >> sys.stderr, inst
    print >> sys.stderr, "Did you properly install Pycornetto using 'setup.py install' ?"
    exit(1)

import webbrowser
import os

from cornetto.argparse import ArgumentParser

parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__)

parser.add_argument(
    "-l",
    "--location",
    default=False,
    action='store_true',
    help='just show where the documention is located on your system')

args = parser.parse_args()

# note that we cannot rely on sys.prefix, because pycornetto may be installed
# in a non.standard location
docpath = os.path.join(
    os.path.dirname(cornetto.__file__),
    "..",  # skip cornetto package dir
                        try:
                            succ_count = succ_lu_form.get("count")
                            old_subcount = int(succ_lu_form.get("subcount", succ_count))
                        except (TypeError, AttributeError):
                            # form or count not found
                            stderr.write("Warning: no <form> element or 'count' attribute in:\n" +
                                         tostring(succ_lu).encode("utf-8") + "\n")
                            continue
                            
                        new_subcount = old_subcount + count
                        succ_lu_form.set("subcount", str(new_subcount))


                        
parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("cdb_lu", type=file,
                    help="xml file specifying the lexical units")

parser.add_argument("cdb_syn", type=file,
                    help="xml file specifying the synsets")

args = parser.parse_args()



c = TweakedCornet(args.cdb_lu, args.cdb_syn)
c.add_sub_counts()
c.write_cdb_lu()
예제 #7
0
import sys

try:
    import cornetto
except ImportError, inst:
    print >>sys.stderr, inst 
    print >>sys.stderr, "Did you properly install Pycornetto using 'setup.py install' ?"
    exit(1)    

import webbrowser
import os

from cornetto.argparse import ArgumentParser


parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__)

parser.add_argument("-l", "--location", default=False, action='store_true',
                    help='just show where the documention is located on your system')

args = parser.parse_args()

# note that we cannot rely on sys.prefix, because pycornetto may be installed
# in a non.standard location
docpath = os.path.join(os.path.dirname(cornetto.__file__),
                       "..", # skip cornetto package dir
                       "..", # skip site-packages
                       "..", # skip pythonx.x
                       "..", # skip lib, now are at what  is normally sys.prefix
                       "share", 
                       "pycornetto-" + __version__,
예제 #8
0
WARNING: this server is not secure and should not run on open networks!
"""

# TODO:
# - forking/threading

__author__ = 'Erwin Marsi <*****@*****.**>'
__version__ = '0.6.1'

from sys import exit
from cornetto.argparse import ArgumentParser, RawDescriptionHelpFormatter
from cornetto.server import start_server

parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("-H",
                    "--host",
                    default="localhost:5204",
                    metavar="HOST[:PORT]",
                    help="name or IP address of host (default is 'localhost') "
                    "optionally followed by a port number "
                    "(default is 5204)")

parser.add_argument('-l', '--log', action='store_true', help="log requests")

parser.add_argument("-m", "--max-depth", type=int)

parser.add_argument('-s',
예제 #9
0
"""

# TODO:
# - forking/threading


__author__ = 'Erwin Marsi <*****@*****.**>'
__version__ = '0.6.1'

from sys import exit
from cornetto.argparse import ArgumentParser, RawDescriptionHelpFormatter
from cornetto.server import start_server


parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("-H", "--host", 
                    default="localhost:5204",
                    metavar="HOST[:PORT]",
                    help="name or IP address of host (default is 'localhost') "
                    "optionally followed by a port number "
                    "(default is 5204)")

parser.add_argument('-l', '--log', 
                    action='store_true', 
                    help="log requests")

parser.add_argument("-m", "--max-depth", 
                    type=int)
예제 #10
0
# TODO:
# - forking/threading

__author__ = 'Erwin Marsi <*****@*****.**>'

__version__ = '0.9'

from sys import exit
from cornetto.argparse import ArgumentParser, RawDescriptionHelpFormatter, SUPPRESS
from cornetto.server import start_server

from daeso_nl.cornetto.server import DaesoCornetProxy, DEFAULT_HOST, DEFAULT_PORT

parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("-H",
                    "--host",
                    default="%s:%d" % (DEFAULT_HOST, DEFAULT_PORT),
                    metavar="HOST[:PORT]",
                    help="name or IP address of host " +
                    "(default is '%s') " % DEFAULT_HOST +
                    "optionally followed by a port number "
                    "(default is %d)" % DEFAULT_PORT)

parser.add_argument('-l', '--log', action='store_true', help="log requests")

parser.add_argument("-m", "--max-depth", type=int)
예제 #11
0
                            succ_count = succ_lu_form.get("count")
                            old_subcount = int(
                                succ_lu_form.get("subcount", succ_count))
                        except (TypeError, AttributeError):
                            # form or count not found
                            stderr.write(
                                "Warning: no <form> element or 'count' attribute in:\n"
                                + tostring(succ_lu).encode("utf-8") + "\n")
                            continue

                        new_subcount = old_subcount + count
                        succ_lu_form.set("subcount", str(new_subcount))


parser = ArgumentParser(description=__doc__,
                        version="%(prog)s version " + __version__,
                        formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("cdb_lu",
                    type=file,
                    help="xml file specifying the lexical units")

parser.add_argument("cdb_syn",
                    type=file,
                    help="xml file specifying the synsets")

args = parser.parse_args()

c = TweakedCornet(args.cdb_lu, args.cdb_syn)
c.add_sub_counts()
c.write_cdb_lu()