Example #1
0
# for importing local modules
import sys
from inspect import currentframe, getfile as i_getfile
from os.path import realpath, abspath, split as p_split, join as p_join

root_path = realpath(
    abspath(p_join(p_split(i_getfile(currentframe()))[0], "..")))
if root_path not in sys.path:
    sys.path.insert(0, root_path)
# -------------------------

import sys
# from scripts_t.measuretime import measure
from utils.parsers import TestParser, OutParser
from utils.MEMM_Taggers import ViterbiTrigramTagger


# @measure
def main(inputf, modelfile, mapfile, outfilename):
    tagger = ViterbiTrigramTagger()
    tagger.loadParams(mapfile, modelfile)

    with OutParser(outfilename) as outF:
        for i, wordsLine in enumerate(TestParser().parseFile(inputf)):
            outF.printLine(tagger.tagLine(wordsLine))


if __name__ == '__main__':
    input_file_name, modelname, feature_map_file, out_file_name = sys.argv[1:5]
    main(input_file_name, modelname, feature_map_file, out_file_name)
Example #2
0
#!/usr/bin/env python
"""
Author: Maxim Kosinov
Specialization: Python, HighLoad Crawlers, Data Mining, Scraping
E-Mail: [email protected]
Skype: geminiozz
O-Desk: Astrey
"""

import sys
import logging
from optparse import OptionParser, OptionGroup
from os.path import split as p_split, join, splitext

# add project dir to PYTHONPATH
sys.path.insert(0, join(p_split(sys.path[0])[0]))

# so now we can import opensyllabus package
from opensyllabus.core.mongo import OpenSyllabusDb
from opensyllabus.core.utils import configure_loggers, log_levels
from opensyllabus.config import GETEMPTY_LOG_FILE, FILE_LOG_VERBOSITY, CONSOLE_LOG_VERBOSITY, LOG_TO_FILE

log = logging.getLogger(__name__)


class BrokenDocsStats(object):
    def __init__(self, log):
        self.broken_ext_count = {}
        #--
        self.db = OpenSyllabusDb(log)
Example #3
0
    matplotlib.use("TkAgg")
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure

import gc
import datetime
import os
from os.path import split as p_split
import json
from tkinter import *
from tkinter import ttk
import numpy as np
import matplotlib.pyplot as plt

settings_home = p_split(p_split(os.getcwd())[0])[0]
sys_path.insert(0, settings_home)
# import procedures
# from procedures import Settings
from lib.core import *

import collections


def nm2pix(nm, abc, add=0):
    nm = float(nm)
    pix = 0
    if 270 < nm < 350:
        ans_nm = pix2nm(abc, pix, 1, add)
        while ans_nm < nm and pix < 1500:
            pix += 1
#!/usr/bin/env python
"""
Author: Maxim Kosinov
Specialization: Python, HighLoad Crawlers, Data Mining, Scraping
E-Mail: [email protected]
Skype: geminiozz
O-Desk: Astrey
"""

import sys
from os.path import split as p_split, join

# add project dir to PYTHONPATH
sys.path.insert(0, join(p_split(sys.path[0])[0]))

# so now we can import opensyllabus package
from opensyllabus.config import DATA_DIR, PROCESS_REPORT_COUNT
from opensyllabus.core.exceptions import WrongFileExtension
from opensyllabus.core.utils import get_data_files, get_file_ext, get_file_dir


class ExtStats(object):
    
    def __init__(self):
        self.counter = 0
        self.ext_stats = {}
        self.valid_count = 0
        self.errors_count = 0
    
    def _show_stats(self):
        """