Example #1
0
    def init_freeling():

        freeling.util_init_locale("default")

        from loacore.conf import lang
        from loacore.conf import LANG_PATH as lpath

        # create the analyzer with the required set of maco_options
        morfo = freeling.maco(my_maco_options(lang, lpath))
        #  then, (de)activate required modules
        morfo.set_active_options(
            False,  # UserMap
            False,  # NumbersDetection,
            True,  # PunctuationDetection,
            False,  # DatesDetection,
            True,  # DictionarySearch,
            False,  # AffixAnalysis,
            False,  # CompoundAnalysis,
            False,  # RetokContractions,
            False,  # MultiwordsDetection,
            False,  # NERecognition,
            False,  # QuantitiesDetection,
            True)  # ProbabilityAssignment

        # create tagger
        tagger = freeling.hmm_tagger(lpath + "tagger.dat", False, 2)

        # create sense annotator
        sen = freeling.senses(lpath + "senses.dat")

        return morfo, tagger, sen
Example #2
0
def init_freeling():
    freeling.util_init_locale("default")

    from loacore.conf import lang
    from loacore.conf import LANG_PATH as lpath

    # create the analyzer with the required set of maco_options
    morfo = freeling.maco(my_maco_options(lang, lpath))

    morfo.set_active_options(
        False,  # UserMap
        False,  # NumbersDetection,
        True,  # PunctuationDetection,
        False,  # DatesDetection,
        True,  # DictionarySearch,
        False,  # AffixAnalysis,
        False,  # CompoundAnalysis,
        True,  # RetokContractions,
        False,  # MultiwordsDetection,
        False,  # NERecognition,
        False,  # QuantitiesDetection,
        False)  # ProbabilityAssignment

    tk = freeling.tokenizer(os.path.join(lpath, "tokenizer.dat"))
    sp = freeling.splitter(os.path.join(lpath, "splitter.dat"))

    return morfo, tk, sp
Example #3
0
def load_all_freeling_modules():

    print("Loading Freeling Modules...")

    import os

    freeling.util_init_locale("default")

    from loacore.conf import lang
    from loacore.conf import LANG_PATH

    # create the analyzer with the required set of maco_options
    morfo = freeling.maco(my_maco_options(lang, LANG_PATH))

    morfo.set_active_options(
        False,  # UserMap
        False,  # NumbersDetection,
        True,  # PunctuationDetection,
        False,  # DatesDetection,
        True,  # DictionarySearch,
        False,  # AffixAnalysis,
        False,  # CompoundAnalysis,
        True,  # RetokContractions,
        False,  # MultiwordsDetection,
        False,  # NERecognition,
        False,  # QuantitiesDetection,
        True)  # ProbabilityAssignment

    tk = freeling.tokenizer(os.path.join(LANG_PATH, "tokenizer.dat"))
    sp = freeling.splitter(os.path.join(LANG_PATH, "splitter.dat"))

    # create tagger
    tagger = freeling.hmm_tagger(os.path.join(LANG_PATH, "tagger.dat"), False,
                                 2)

    # create sense annotator
    sen = freeling.senses(os.path.join(LANG_PATH, "senses.dat"))
    # create sense disambiguator
    wsd = freeling.ukb(os.path.join(LANG_PATH, "ukb.dat"))
    # create dependency parser
    parser = freeling.dep_treeler(
        os.path.join(LANG_PATH, "dep_treeler", "dependences.dat"))
    print("Done.")

    return {
        "tk": tk,
        "sp": sp,
        "morfo": morfo,
        "tagger": tagger,
        "sen": sen,
        "wsd": wsd,
        "parser": parser
    }
Example #4
0
def init_freeling():

    freeling.util_init_locale("default")

    from loacore.conf import lang
    from loacore.conf import LANG_PATH as lpath

    # create the analyzer with the required set of maco_options
    morfo = freeling.maco(my_maco_options(lang, lpath))

    morfo.set_active_options(
        False,  # UserMap
        False,  # NumbersDetection,
        True,  # PunctuationDetection,
        False,  # DatesDetection,
        True,  # DictionarySearch,
        False,  # AffixAnalysis,
        False,  # CompoundAnalysis,
        False,  # RetokContractions,
        False,  # MultiwordsDetection,
        False,  # NERecognition,
        False,  # QuantitiesDetection,
        True)  # ProbabilityAssignment

    # create tagger
    tagger = freeling.hmm_tagger(os.path.join(lpath, "tagger.dat"), False, 2)

    # create sense annotator
    sen = freeling.senses(os.path.join(lpath, "senses.dat"))
    # create sense disambiguator
    wsd = freeling.ukb(os.path.join(lpath, "ukb.dat"))
    # create dependency parser
    parser = freeling.dep_treeler(
        os.path.join(lpath, "dep_treeler", "dependences.dat"))

    return morfo, tagger, sen, wsd, parser
Example #5
0
    opt.LocutionsFile = lpath + "locucions.dat";
    opt.AffixFile = lpath + "afixos.dat";
    opt.ProbabilityFile = lpath + "probabilitats.dat";
    opt.DictionaryFile = lpath + "dicc.src";
    opt.NPdataFile = lpath + "np.dat";
    opt.PunctuationFile = lpath + "../common/punct.dat";
    return opt;



## ----------------------------------------------
## -------------    MAIN PROGRAM  ---------------
## ----------------------------------------------

# set locale to an UTF8 compatible locale
freeling.util_init_locale("default");

# get requested language from arg1, or English if not provided
lang = "en"
if len(sys.argv)>1 : lang=sys.argv[1]

# get installation path to use from arg2, or use /usr/local if not provided
ipath = INSTALLATION_PATH
if len(sys.argv)>2 : ipath=sys.argv[2]

# path to language data
lpath = os.path.join(ipath, "share", "freeling", lang, "")

# create analyzers
tk=freeling.tokenizer(lpath+"tokenizer.dat");
sp=freeling.splitter(lpath+"splitter.dat");