我正在评估我使用Spacy构建的自定义NER模型.我正在使用Spacy的Scorer课程评估训练集.
def Eval(examples):
# test the saved model
print("Loading from", './model6/')
ner_model = spacy.load('./model6/')
scorer = Scorer()
try:
for input_, annot in examples:
doc_gold_text = ner_model.make_doc(input_)
gold = GoldParse(doc_gold_text, entities=annot['entities'])
pred_value = ner_model(input_)
scorer.score(pred_value, gold)
except Exception as e: print(e)
print(scorer.scores)
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我不明白输出.这是我为每个训练集获得的内容.
{'uas': 0.0, 'las': 0.0, 'ents_p': 90.14084507042254, 'ents_r': 92.7536231884058, 'ents_f': 91.42857142857143, 'tags_acc': 0.0, 'token_acc': 100.0}
{'uas': 0.0, 'las': 0.0, 'ents_p': 91.12227805695142, 'ents_r': 93.47079037800687, 'ents_f': 92.28159457167091, 'tags_acc': 0.0, 'token_acc': 100.0}
{'uas': 0.0, 'las': 0.0, 'ents_p': 92.45614035087719, 'ents_r': 92.9453262786596, 'ents_f': 92.70008795074759, …Run Code Online (Sandbox Code Playgroud) 我最近添加了HaveIBeenPwned添加到我的表单请求类中以检查密码是否被破解。鉴于这会进行外部 API 调用,有没有办法让我在测试期间完全跳过此验证规则或 FormRequest 类?
这是我在测试中提出的要求。
$params = [
'first_name' => $this->faker->firstName(),
'last_name' => $this->faker->lastName(),
'email' => $email,
'password' => '$password',
'password_confirmation' => '$password',
'terms' => true,
'invitation' => $invitation->token
];
$response = $this->json('POST', '/register-invited', $params);
Run Code Online (Sandbox Code Playgroud)
我正在测试的功能驻留在控制器上。在我的测试中,我使用以下规则发布了通过 FormRequest 传递的数据数组。
public function rules()
{
return [
'first_name' => 'required|string|max:70',
'last_name' => 'required|string|max:70',
'email' =>
'required|email|unique:users,email|max:255|exists:invitations,email',
'password' => 'required|string|min:8|pwned|confirmed',
'is_trial_user' => 'nullable|boolean',
'terms' => 'required|boolean|accepted',
];
}
Run Code Online (Sandbox Code Playgroud)
我想覆盖密码上的“pwned”规则,这样我就可以访问控制器,而不必担心通过验证。
我一直在研究Laravel Telescope,它提到了仅在本地环境中运行而不是在生产环境中运行的能力,方法是将以下代码片段包含在AppServiceProvider.
public function register()
{
if ($this->app->isLocal()) {
$this->app->register(TelescopeServiceProvider::class);
}
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我试图弄清楚该isLocal()方法到底是做什么的。到目前为止,我还没有找到太多信息。
谢谢,
我正在尝试创建一个用于Angular开发的docker容器。
使用与下面的几乎相同的dockerfile,我能够为React创建一个开发容器。
FROM node:8.9.0
ENV NPM_CONFIG_LOGLEVEL warn
ARG app_env
ENV APP_ENV $app_env
RUN mkdir -p /app1
WORKDIR /app1
COPY ./app1 ./
COPY app1/package.json /app1
RUN npm install
RUN npm update
RUN npm install -g typescript
EXPOSE 4200
RUN chmod a+x /app1/node_modules/.bin/*
ENTRYPOINT ["tail", "-f", "/dev/null"]
#ENTRYPOINT npm start
Run Code Online (Sandbox Code Playgroud)
要运行容器,我使用:
docker run -i -t -p 4200:4200 -v /var/react/{your app name}/{Your apps sub folder}/src:/{ Your apps sub folder } /src {container ID}
Run Code Online (Sandbox Code Playgroud)
然后,我进入容器并运行npm start或npm start 0.0.0.0:4200。一切都编译成功,并说它应该在运行,localhost:4200但出现连接拒绝错误。 …
我有一个如下所示的基本形式。我调用一个 API 来获取用户的个人信息,我想用适当的值填充表单字段。我一直在尝试使用,patchValue但我无法让它工作。
<form (ngSubmit)="onSubmit" class="example-form" [formGroup]="firstFormGroup" #registerForm="ngForm">
<mat-form-field class="example-full-width">
<input matInput placeholder="Company" formControlName="company" required autofocus>
<mat-error *ngIf="firstFormGroup.get('company').hasError('required')">
Company name is
<strong>required</strong>
</mat-error>
</mat-form-field>
<table class="example-full-width" cellspacing="0">
<tr>
<td>
<mat-form-field class="example-full-width">
<input matInput placeholder="First name" formControlName="first_name" required>
<mat-error *ngIf="firstFormGroup.get('first_name').hasError('required')">
First name is
<strong>required</strong>
</mat-error>
</mat-form-field>
</td>
<td>
<mat-form-field class="example-full-width">
<input matInput placeholder="Last Name" formControlName="last_name" required>
<mat-error *ngIf="firstFormGroup.get('last_name').hasError('required')">
Last name is
<strong>required</strong>
</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
<td>
<mat-form-field class="example-full-width">
<input matInput placeholder="Email" formControlName="email" required>
<mat-error *ngIf="firstFormGroup.get('email').hasError('email') && !email.hasError('required')"> …Run Code Online (Sandbox Code Playgroud)