本文整理汇总了Python中settings.Settings.get_directory方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.get_directory方法的具体用法?Python Settings.get_directory怎么用?Python Settings.get_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.get_directory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ArgumentParser
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_directory [as 别名]
from argparse import ArgumentParser
from pdf_classes import *
if __name__ == "__main__":
parser = ArgumentParser(description='Evaluate a model on the test set')
parser.add_argument('model_file', help='the model definition YAML file',
default=None)
parser.add_argument('--settings', help='the path to the settings file',
default=None)
parser.add_argument('--token', help='a token for exported data',
default=None)
args = parser.parse_args()
settings = Settings(args.settings)
with open(os.path.join(settings.get_directory('model'), args.model_file)) as f:
model_def = yaml.load(f)
field_name = model_def['field']
field = settings.fields[field_name]
with open(os.path.join(settings.get_directory('pickle'),
'%s.pkl' % args.model_file), 'r') as f:
wrapper = pickle.load(f)
y = []
X = []
settings.map_tables()
session = settings.session()
token = args.token
示例2: ArgumentParser
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_directory [as 别名]
from argparse import ArgumentParser
from pdf_classes import *
if __name__ == "__main__":
parser = ArgumentParser(description='Choose model parameters by cross-validation')
parser.add_argument('model_file', help='the model definition YAML file',
default=None)
parser.add_argument('--settings', help='the path to the settings file',
default=None)
parser.add_argument('--token', help='a token for exported data',
default=None)
args = parser.parse_args()
settings = Settings(args.settings)
with open(os.path.join(settings.get_directory('model'), args.model_file)) as f:
model_def = yaml.load(f)
field_name = model_def['field']
field = settings.fields[field_name]
parameters = model_def.get('parameters', {})
n_jobs = model_def.get('n_jobs', 1)
use_probability = model_def.get('use_probability', False)
wrapper = estimators.ModelWrapper(field, model_def['threshold'], model_def['module'],
model_def['class'], model_params=parameters,
use_probability=use_probability)
y = []
X = []
示例3: Settings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_directory [as 别名]
parser.add_argument('--schema', help='install the schema', action='store_true')
parser.add_argument('--settings', help='the path to the settings file',
default=None)
args = parser.parse_args()
settings = Settings(args.settings)
metadata = settings.map_tables()
if args.schema:
#Just install the schema.
metadata.create_all(settings.engine())
else:
#Extract all of the PDFs in the pdf directory to the database.
session = settings.session()
pdf_dir = settings.get_directory('pdf')
existing = [fn[0] for fn in session.query(Document.filename)]
labels = settings.load_labels()
for filename in os.listdir(pdf_dir):
if filename not in existing:
file_labels = labels.get(filename, {})
try:
with open(os.path.join(pdf_dir, filename), "r") as fp:
extract_pdf_data(fp, settings.test_proportion, file_labels, session)
except Exception as e:
session.rollback()
print (filename, e)
示例4: make_rectangle
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_directory [as 别名]
c.setStrokeColorRGB(0,0,1)
make_rectangle(c, char.bbox)
c.showPage()
c.save()
pdf_content = PdfReader(clean_path)
for i,page in enumerate(pdf_content.pages):
rects = PageMerge().add(PdfReader(rect_file).pages[i])[0]
PageMerge(page).add(rects).render()
PdfWriter().write(marked_path, pdf_content)
os.remove(rect_file)
except Exception as e:
print(e)
if __name__ == "__main__":
argparser = ArgumentParser(description = 'Mark blocks, lines and characters in a PDF')
argparser.add_argument('filename', help='the name of the file to mark up')
argparser.add_argument('--settings', help='the path to the settings file',
default=None)
args = argparser.parse_args()
settings = Settings(args.settings)
pdf_dir = settings.get_directory('pdf')
marked_pdf_dir = settings.get_directory('marked_pdf')
clean_path = os.path.join(pdf_dir, args.filename)
marked_path = os.path.join(marked_pdf_dir, args.filename)
mark_pdf(clean_path, marked_path)
示例5: ArgumentParser
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get_directory [as 别名]
from os import path
import uuid
if __name__ == "__main__":
parser = ArgumentParser(description="Compute features for lines")
parser.add_argument("--settings", help="the path to the settings file", default=None)
parser.add_argument("--fields", help="the fields to generate data for", nargs="*", default=None)
parser.add_argument(
"--test", help="flag indicating that test set should be used", action="store_true", default=False
)
args = parser.parse_args()
settings = Settings(args.settings)
settings.map_tables()
session = settings.session()
csv_directory = settings.get_directory("csv")
token = uuid.uuid1()
dataset = "test" if args.test else "training"
# If field names have been specified on the command line, only export those ones.
fields = settings.fields
if args.fields is not None:
fields = {name: field for name, field in fields.iteritems() if name in args.fields}
# Get all candidates for all fields.
candidates = {field_name: [] for field_name in fields}
for document in session.query(Document).options(joinedload(Document.lines)).filter(Document.is_test == args.test):
for field_name, field in fields.iteritems():
if getattr(document, field_name) is None:
continue