This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
AEX.h
75 lines (60 loc) · 2.1 KB
/
AEX.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// AEX.h
// AssistantExtensions
//
// Created by K3A on 3/19/12.
// Copyright (c) 2012 K3A. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SiriObjects.h"
@interface AEPatternMatchImpl : NSObject <AEPatternMatch> {
NSString* _lang;
NSString* _text;
NSMutableArray* _tokens;
NSSet* _tokenSet;
id _userInfo;
NSMutableDictionary* _namedElements;
NSMutableArray* _vectorElements;
}
+(id)patternMatchForText:(NSString*)text language:(NSString*)lang userInfo:(id)ui;
-(id)initWithText:(NSString*)text language:(NSString*)lang userInfo:(id)ui;
-(void)addElement:(NSString*)elem;
-(void)addElement:(NSString*)elem forName:(NSString*)name;
@end
struct AEPatternSubtoken {
enum eAEPST {
EXACT = 0, // exact word match (including splitwords by ~) ; default
FUZZY, // fuzzy matching (including splitwords by ~)
WORD, // must be <word>
ALPHA, // must be <alpha>
NUMBER, // must be <number>
ALPHANUM, // <alphanum>
PERSON, // <person> addressbook lookup
};
NSString* part1; // only used for split words (a~b)
NSString* part2; // only used for split words (a~b)
NSString* word;
unsigned long hash1; // token hash, 0 if not possible
unsigned long hash2; // token hash, 0 if not possible
unsigned long wordHash; // token hash, 0 if not possible
enum eAEPST type;
struct AEPatternSubtoken* next;
};
@interface AEPattern : NSObject {
@private
struct AEPatternToken* _first;
NSString* _description;
id _target;
SEL _sel;
id _userInfo;
}
+(id)patternWithString:(NSString*)pat target:(id)target selector:(SEL)sel userInfo:(id)user;
-(id)initWithPatternString:(NSString*)pat target:(id)target selector:(SEL)sel userInfo:(id)user;
/// tries if this pattern matches and if so executes handling method and returns TRUE
-(BOOL)execute:(NSString*)input language:(NSString*)lang context:(id<SEContext>)ctx;
/// immediately fires the target on specified selector
-(BOOL)fireWithMatch:(id<AEPatternMatch>)match context:(id<SEContext>)ctx;
-(id)target;
-(SEL)selector;
-(id)userInfo;
@end