我正在尝试使用spaCy创建一个新的实体分类'Species',其中包含物种名称列表,例如,他可以在这里找到.
我从这个spaCy教程(这里是 Github代码)中找到了一个培训新实体类型的教程.然而,问题是,我不想为每个物种名称手动创建一个句子,因为它会非常耗时.
我在下面创建了训练数据,如下所示:
TRAIN_DATA = [('Bombina',{'entities':[(0,6,'SPECIES')]}),
('Dermaptera',{'entities':[(0,9,'SPECIES')]}),
....
]
Run Code Online (Sandbox Code Playgroud)
我创建训练集的方式是:不是提供完整的句子和匹配实体的位置,而是仅提供每个物种的名称,并以编程方式生成开始和结束索引:
[(0,6,'种类')]
[(0,9,'种类')]
训练代码下面是我用来训练模型的.(从上面的超链接复制的代码)
nlp = spacy.blank('en') # create blank Language class
# Add entity recognizer to model if it's not in the pipeline
# nlp.create_pipe works for built-ins that are registered with spaCy
if 'ner' not in nlp.pipe_names:
ner = nlp.create_pipe('ner')
nlp.add_pipe(ner)
# otherwise, get it, so we can add labels to it
else:
ner = nlp.get_pipe('ner')
ner.add_label(LABEL) # add …Run Code Online (Sandbox Code Playgroud) 在我的项目中,我需要每分钟自动拍照.但我找不到任何解决方案.
这是我实现的代码,但它不起作用......
我使用NSTimer调用相机每4秒拍照.我只需要这个东西
//This method is all for the time setup. You can ignore it.
-(NSDate *)userInfo {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd 'at' HH:mm:ss"];
NSDate *date = [[[NSDate alloc]init]autorelease];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
NSLog(@"formattedDateString: %@", formattedDateString);
return date;
}
- (void)targetMethod:(NSTimer *)theTimer {
NSDate *startDate = [self userInfo];
//newly changed lines.
UIImagePickerController *myPicker;
[myPicker takePicture];
NSLog(@"Timer started on %@", startDate);
}
- (IBAction) showCameraUI {
[NSTimer scheduledTimerWithTimeInterval:4.0
target:self
selector: @selector(targetMethod:)
userInfo:[self userInfo]
repeats:YES];
}
Run Code Online (Sandbox Code Playgroud) 我是objective-c的新手,我在UIImagePickerControllerMediaMetaData中读取信息时遇到问题.
-(void) imagePickerController:(UIImagePickerController *)imagepicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
//This line is fine.
NSDictionary *metadata = [info objectForKey:UIImagePickerControllerMediaMetadata];
//This line fail to operate...
NSArray *tiffData = [metadata objectForKey:Exif];
Run Code Online (Sandbox Code Playgroud)
我可以获取元数据.但是,元数据中的信息有点令人困惑,下面显示了内部元数据.
UIImagePickerControllerMediaMetadata = {
DPIHeight = 72;
DPIWidth = 72;
Orientation = 6;
"{Exif}" = {
ApertureValue = "2.526068811667588";
BrightnessValue = "-1.739497174308802";
ColorSpace = 1;
DateTimeDigitized = "2012:02:21 11:53:44";
DateTimeOriginal = "2012:02:21 11:53:44";
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666666666666667";
FNumber = "2.4";
Flash = 32;
FocalLenIn35mmFilm = 32;
FocalLength = "2.03"; …Run Code Online (Sandbox Code Playgroud) 我有两个不同处理方法收集的两个数据样本:
sam.a <- c( 0.1333333, 0.2258065, 0.1944444, 0.2894737)
sam.b <- c(0.137931, 0.093750, 0, 0)
Run Code Online (Sandbox Code Playgroud)
我首先在R中尝试了t.test:
t.test(sam.a,sam.b)
Run Code Online (Sandbox Code Playgroud)
这给了我如下结果(p < 0.05):
Welch Two Sample t-test
data: sam.a and sam.b
t = -4.1497, df = 5.8602, p-value = 0.006329
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.27151717 -0.06935361
sample estimates:
mean of x mean of y
0.1994576 0.3698930
Run Code Online (Sandbox Code Playgroud)
当我在R中使用anova尝试相同的数据时:
aov(sam.a ~ sam.b)
Run Code Online (Sandbox Code Playgroud)
结果变得微不足道(p > 0.05):
Df Sum Sq Mean Sq F …Run Code Online (Sandbox Code Playgroud) objective-c ×2
xcode ×2
anova ×1
api ×1
nested ×1
nlp ×1
nsdictionary ×1
python ×1
python-3.x ×1
r ×1
spacy ×1
statistics ×1