• Stars
    star
    410
  • Rank 105,468 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An iOS search engine that allows mistakes in the searched element.

My other works

[http://leverdeterre.github.io] (http://leverdeterre.github.io)

Twitter License MIT Cocoapods

PermissiveResearch

An iOS search engine that allows mistakes in the searched element in huge data. Many developpers would have executed a fectch request on a CoreData database or a predicate to filter on a NSArray.

Image

PermissiveResearch is a alternative to simplify the search step. Advantages :

  • No more problems with CoreData (context/thread),
  • Performances,
  • 100% resusable for each projects that need to perform analysis in huge data,
  • Search algorithm are easy customizable,
  • 3 algorithms already implemented,

Performances (on iphone4, searchig in 5000 objects 4 properties)

Type of search time (ms) data structure
Exact search 200 Using predicates
Exact search 2800 Using PermissiveResearch (ExactScoringOperation*)
Exact search 100 Using PermissiveResearch (HeuristicScoringOperation*)
Exact search 700 Using PermissiveResearch (HeurexactScoringOperation*)
Tolerated search impossible.. Using predicates
Tolerated search 2800 Using PermissiveResearch (ExactScoringOperation*)
Tolerated search 100 Using PermissiveResearch (HeuristicScoringOperation*)
Tolerated search 700 Using PermissiveResearch (HeurexactScoringOperation*)
  • ExactScoringOperation : Make a complex and total analysis,
  • HeuristicScoringOperation : Scan using fragments (default size 3),
  • HeurexactScoringOperation : Scan using fragments (default size 3), then make a complex and total analysis of the best pre-selected objects.

Algorithms

It's a custom implementation of the [Smith-Waterman algorithm][1]. The purpose of the algorithm is to obtain the optimum local alignment. A similarity matrix is use to tolerate errors. [1]: http://en.wikipedia.org/wiki/Smith–Waterman_algorithm

Shared instance

[[PermissiveResearchDatabase sharedDatabase] setDatasource:self];

Datasource methods to fill your search database

-(void)rebuildDatabase
- (void)addObject:(id)obj forKey:(NSString *)key;
- (void)addObjects:(NSArray *)obj forKey:(NSString *)key;
- (void)addObjects:(NSArray *)objs forKeys:(NSArray *)keys;
- (void)addObjects:(NSArray *)objs forKeyPaths:(NSArray *)KeyPaths;

- (void)addManagedObject:(NSManagedObject *)obj forKey:(NSString *)key;
- (void)addManagedObjects:(NSArray *)objs forKey:(NSString *)key;
- (void)addManagedObjects:(NSArray *)objs forKeys:(NSArray *)keys;
- (void)addManagedObjects:(NSArray *)objs forKeyPaths:(NSArray *)KeyPaths;

Example :

///PermissiveResearchDatabase datasource
-(void)rebuildDatabase
{
    NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"data5000"
                                                         ofType:@"json"];
    NSData *data = [NSData dataWithContentsOfFile:jsonPath];
    NSError *error = nil;
    id json = [NSJSONSerialization JSONObjectWithData:data
                                              options:kNilOptions
                                                error:&error];
    
    [[PermissiveResearchDatabase sharedDatabase] addObjects:json forKeyPaths:@[@"name",@"gender",@"company",@"email"]];
    self.searchedList = json;
}

Datasource method to customize scoring methods

-(NSInteger)customCostForEvent:(ScoringEvent)event

Example (default values) :

-(NSInteger)customCostForEvent:(ScoringEvent)event
{
    switch (event) {
        case ScoringEventPerfectMatch:
            return 2;
            break;
           
        case ScoringEventNotPerfectMatchKeyboardAnalyseHelp:
            return 1;
            break;
            
        case ScoringEventNotPerfectBecauseOfAccents:
            return 2;
            break;
            
        case ScoringEventLetterAddition:
            return -1;
            break;
            
        default:
            break;
    }
    
    return NSNotFound;
}

Easy search operation using PermissiveResearch delegate


[[PermissiveResearchDatabase sharedDatabase] setDelegate:self];
[[PermissiveResearchDatabase sharedDatabase] searchString:searchedString withOperation:ScoringOperationTypeExact];
    
#pragma mark PermissiveResearchDelegate

-(void)searchCompletedWithResults:(NSArray *)results
{
    dispatch_async(dispatch_get_main_queue(), ^{
        self.findedElements = results;
        [self.tableView reloadData];
    });
}

Create your first search operation


    [[ScoringOperationQueue mainQueue] cancelAllOperations]
    HeuristicScoringOperation *ope = [[HeuristicScoringOperation alloc] init];
    ope.searchedString = searchedString;
    
    SearchCompletionBlock block = ^(NSArray *results) {
        dispatch_async(dispatch_get_main_queue(), ^{
            self.findedElements = results;
            NSLog(@"finded elements %@", results);
        });
    };
    
    [ope setCustomCompletionBlock:block];
    [[ScoringOperationQueue mainQueue] addOperation:ope];

Actualy 3 operations are available, usage depends on the performance you need.

Algorithms complexities are very differents. HeuristicScoringOperation < HeurexactScoringOperation << ExactScoringOperation

ExactScoringOperation
HeuristicScoringOperation
HeurexactScoringOperation

TODO

  • Tolerate keyboard errors, very proximal letters can be tolerate.

More Repositories

1

CalendarIOS7

Calendar component for iOS apps
Objective-C
560
star
2

JMHoledView

A view design to be filled with holes ...
Objective-C
546
star
3

JMAnimatedImageView

Subclass of UIImageView to drive easy animations (manual rotation, Carousel, GIF support)
Objective-C
406
star
4

JMActionSheetDescription

ActionSheet and UIActivityViewController replacement, using a descriptor component.
Objective-C
334
star
5

iAppInfos

iAppInfos allows a easy access to ALL important App informations : iOS version, Device model, Free Disk Space, Mobile provisionning infos
Objective-C
190
star
6

CustomScrollIndicator

iOS custom ScrollIView indicator
Objective-C
183
star
7

UINavigationControllerWithCompletionBlock

The UINavigationControllerWithCompletionBlock missing API !
Objective-C
139
star
8

JMOTableViewDescription

JMOTableViewDescription is an Objective-C library for easily creating and manage complex structured tableView.
Objective-C
73
star
9

LanguagesManager

An easy way to control manually the language in your application
Objective-C
64
star
10

JMCache

JMCache is a key/value store designed for persisting temporary objects. Particularities?? (NSCoding is not mandatory, you can add custom transformer to secure your data)
Objective-C
61
star
11

SecureMappingKit

Securize the mapping between your JSON and your model.
Objective-C
39
star
12

JMFormDescription

JMFormDescription is an Objective-C library for easily creating and manage complex structured Form.
Objective-C
31
star
13

JMImageScanning

Basic ocr recognition to hack secure keyboards
Objective-C
26
star
14

conference-download-scripts

Amazing videos are available but i want to see it offline
Shell
13
star
15

JMSystemNotifications

JMSystemNotifications is an Objective-C library for easily register/unregister OS System notifications
Objective-C
9
star
16

JMCrashIfResign

JMCrashIfResign is a way to protect your application against bad usage
Objective-C
8
star
17

postman

Postman iOS app to edit/execute Postman collections
Objective-C
7
star
18

ApplicationLoader-Errors

A lot of errors can occurs during Application submission !
7
star
19

JMDynamicDeviceName

JMDynamicDeviceName
Shell
4
star
20

MediaPickerManager

Shared object that allow to simplify UIImagePickerController
Objective-C
4
star
21

shakeMyApps-appScan-blog

HTML
3
star
22

DesignPatterns

Cocoa common design patterns
Objective-C
2
star
23

MaryToastin

Toast component using MaryPopin module
Objective-C
2
star
24

JMAnimationDescription

Describe your animation, i'm doing it
Objective-C
1
star
25

HexaColor

A library to parse Hexa string colors
Shell
1
star
26

bitly_ios_sdk

Objective-C
1
star
27

OneSignal-NodeJS-SDK

1
star
28

twitterCleaner

A simple OSX command line to purge yours "friends" (after an account hack for example ... in my case)
Objective-C
1
star
29

try_git

1
star
30

xctool-log2junit

A tool to convert your Xcodebuild tests output to a JUnit formated results
Shell
1
star