mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
Merge branch 'NSLinguisticTagger_branch'
This commit is contained in:
commit
245e3927df
6 changed files with 683 additions and 0 deletions
|
@ -95,6 +95,7 @@
|
|||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSKeyValueObserving.h>
|
||||
#import <Foundation/NSLengthFormatter.h>
|
||||
#import <Foundation/NSLinguisticTagger.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSLocale.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
|
@ -111,6 +112,7 @@
|
|||
#import <Foundation/NSObjectScripting.h>
|
||||
#import <Foundation/NSOperation.h>
|
||||
#import <Foundation/NSOrderedSet.h>
|
||||
#import <Foundation/NSOrthography.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSPersonNameComponents.h>
|
||||
#import <Foundation/NSPersonNameComponentsFormatter.h>
|
||||
|
|
239
Headers/Foundation/NSLinguisticTagger.h
Normal file
239
Headers/Foundation/NSLinguisticTagger.h
Normal file
|
@ -0,0 +1,239 @@
|
|||
/* Definition of class NSLinguisticTagger
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento <greg.casamento@gmail.com>
|
||||
Date: Sat Nov 2 21:37:50 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSLinguisticTagger_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSLinguisticTagger_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSRange.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSString, NSArray, NSOrthography;
|
||||
|
||||
typedef NSString* NSLinguisticTagScheme;
|
||||
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeTokenType;
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeLexicalClass;
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeNameType;
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeNameTypeOrLexicalClass;
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeLemma;
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeLanguage;
|
||||
GS_EXPORT NSLinguisticTagScheme const NSLinguisticTagSchemeScript;
|
||||
|
||||
typedef NSString* NSLinguisticTag;
|
||||
|
||||
/* Tags for NSLinguisticTagSchemeTokenType */
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagWord;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagPunctuation;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagWhitespace;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOther;
|
||||
|
||||
/* Tags for NSLinguisticTagSchemeLexicalClass */
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagNoun;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagVerb;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagAdjective;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagAdverb;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagPronoun;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagDeterminer;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagParticle;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagPreposition;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagNumber;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagConjunction;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagInterjection;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagClassifier;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagIdiom;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOtherWord;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagSentenceTerminator;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOpenQuote;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagCloseQuote;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOpenParenthesis;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagCloseParenthesis;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagWordJoiner;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagDash;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOtherPunctuation;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagParagraphBreak;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOtherWhitespace;
|
||||
|
||||
/* Tags for NSLinguisticTagSchemeNameType */
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagPersonalName;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagPlaceName;
|
||||
GS_EXPORT NSLinguisticTag const NSLinguisticTagOrganizationName;
|
||||
|
||||
enum
|
||||
{
|
||||
NSLinguisticTaggerUnitWord,
|
||||
NSLinguisticTaggerUnitSentence,
|
||||
NSLinguisticTaggerUnitParagraph,
|
||||
NSLinguisticTaggerUnitDocument
|
||||
};
|
||||
typedef NSUInteger NSLinguisticTaggerUnit;
|
||||
|
||||
enum
|
||||
{
|
||||
NSLinguisticTaggerOmitWords = 1 << 0,
|
||||
NSLinguisticTaggerOmitPunctuation = 1 << 1,
|
||||
NSLinguisticTaggerOmitWhitespace = 1 << 2,
|
||||
NSLinguisticTaggerOmitOther = 1 << 3,
|
||||
NSLinguisticTaggerJoinNames = 1 << 4
|
||||
};
|
||||
typedef NSUInteger NSLinguisticTaggerOptions;
|
||||
|
||||
DEFINE_BLOCK_TYPE(GSLinguisticTagRangeBoolBlock, void, NSLinguisticTag, NSRange, BOOL);
|
||||
DEFINE_BLOCK_TYPE(GSLinguisticTagRangeRangeBoolBlock, void, NSLinguisticTag, NSRange, NSRange, BOOL);
|
||||
|
||||
@interface NSLinguisticTagger : NSObject
|
||||
{
|
||||
NSArray *_schemes;
|
||||
NSString *_string;
|
||||
NSString *_dominantLanguage;
|
||||
NSArray *_tokenArray;
|
||||
NSArray *_orthographyArray;
|
||||
NSUInteger _options;
|
||||
}
|
||||
|
||||
- (instancetype) initWithTagSchemes: (NSArray *)tagSchemes
|
||||
options: (NSUInteger)opts;
|
||||
|
||||
- (NSArray *) tagSchemes;
|
||||
|
||||
- (NSString *) string;
|
||||
- (void) setString: (NSString *)string;
|
||||
|
||||
+ (NSArray *) availableTagSchemesForUnit: (NSLinguisticTaggerUnit)unit
|
||||
language: (NSString *)language;
|
||||
|
||||
+ (NSArray *) availableTagSchemesForLanguage: (NSString *)language;
|
||||
|
||||
- (void) setOrthography: (NSOrthography *)orthography
|
||||
range: (NSRange)range;
|
||||
|
||||
- (NSOrthography *) orthographyAtIndex: (NSUInteger)charIndex
|
||||
effectiveRange: (NSRangePointer)effectiveRange;
|
||||
|
||||
- (void) stringEditedInRange: (NSRange)newRange
|
||||
changeInLength: (NSInteger)delta;
|
||||
|
||||
- (NSRange) tokenRangeAtIndex: (NSUInteger)charIndex
|
||||
unit: (NSLinguisticTaggerUnit)unit;
|
||||
|
||||
- (NSRange) sentenceRangeForRange: (NSRange)range;
|
||||
|
||||
- (void) enumerateTagsInRange: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
usingBlock: (GSLinguisticTagRangeBoolBlock)block;
|
||||
|
||||
- (NSLinguisticTag) tagAtIndex: (NSUInteger)charIndex
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
tokenRange: (NSRangePointer)tokenRange;
|
||||
|
||||
- (NSArray *) tagsInRange: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
tokenRanges: (NSArray **)tokenRanges;
|
||||
|
||||
- (void) enumerateTagsInRange: (NSRange)range
|
||||
scheme: (NSLinguisticTagScheme)tagScheme
|
||||
options: (NSLinguisticTaggerOptions)opts
|
||||
usingBlock: (GSLinguisticTagRangeRangeBoolBlock)block;
|
||||
|
||||
- (NSLinguisticTag) tagAtIndex: (NSUInteger)charIndex
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
tokenRange: (NSRangePointer)tokenRange
|
||||
sentenceRange: (NSRangePointer)sentenceRange;
|
||||
|
||||
- (NSArray *) tagsInRange: (NSRange)range
|
||||
scheme: (NSString *)tagScheme
|
||||
options: (NSLinguisticTaggerOptions)opts
|
||||
tokenRanges: (NSArray **)tokenRanges;
|
||||
|
||||
- (NSString *) dominantLanguage;
|
||||
|
||||
+ (NSString *) dominantLanguageForString: (NSString *)string;
|
||||
|
||||
+ (NSLinguisticTag) tagForString: (NSString *)string
|
||||
atIndex: (NSUInteger)charIndex
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
orthography: (NSOrthography *)orthography
|
||||
tokenRange: (NSRangePointer)tokenRange;
|
||||
|
||||
+ (NSArray *)tagsForString: (NSString *)string
|
||||
range: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
orthography: (NSOrthography *)orthography
|
||||
tokenRanges: (NSArray **)tokenRanges;
|
||||
|
||||
+ (void) enumerateTagsForString: (NSString *)string
|
||||
range: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
orthography: (NSOrthography *)orthography
|
||||
usingBlock: (GSLinguisticTagRangeBoolBlock)block;
|
||||
|
||||
|
||||
- (NSArray *) possibleTagsAtIndex: (NSUInteger)charIndex
|
||||
scheme: (NSString *)tagScheme
|
||||
tokenRange: (NSRangePointer)tokenRange
|
||||
sentenceRange: (NSRangePointer)sentenceRange
|
||||
scores: (NSArray **)scores;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSString (NSLinguisticAnalysis)
|
||||
|
||||
- (NSArray *) linguisticTagsInRange: (NSRange)range
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
orthography: (NSOrthography *)orthography
|
||||
tokenRanges: (NSArray **)tokenRanges;
|
||||
|
||||
- (void) enumerateLinguisticTagsInRange: (NSRange)range
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
orthography: (NSOrthography *)orthography
|
||||
usingBlock: (GSLinguisticTagRangeRangeBoolBlock)block;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSLinguisticTagger_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
69
Headers/Foundation/NSOrthography.h
Normal file
69
Headers/Foundation/NSOrthography.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* Definition of class NSOrthography
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Tue Nov 5 03:43:39 EST 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSOrthography_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSOrthography_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSDictionary, NSString, NSArray;
|
||||
|
||||
@interface NSOrthography : NSObject <NSCopying, NSCoding>
|
||||
{
|
||||
NSDictionary *_languageMap;
|
||||
NSString *_dominantScript;
|
||||
}
|
||||
|
||||
- (instancetype) initWithDominantScript: (NSString *)script
|
||||
languageMap: (NSDictionary *)map;
|
||||
|
||||
- (NSString *) dominantScript;
|
||||
- (NSDictionary *) languationMap;
|
||||
|
||||
- (NSArray *) languagesForScript: (NSString *)script;
|
||||
- (NSString *) dominantLanguageForScript: (NSString *)script;
|
||||
|
||||
- (NSString *) dominantLanguage;
|
||||
- (NSArray *) allScripts;
|
||||
- (NSArray *) allLanguages;
|
||||
|
||||
+ (instancetype) defaultOrthographyForLanguage: (NSString *)language;
|
||||
+ (instancetype) orthographyWithDominantScript: (NSString *)script languageMap: (NSDictionary *)map;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSOrthography_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
|
@ -253,6 +253,7 @@ NSKeyedUnarchiver.m \
|
|||
NSKeyValueCoding.m \
|
||||
NSKeyValueObserving.m \
|
||||
NSLengthFormatter.m \
|
||||
NSLinguisticTagger.m \
|
||||
NSLocale.m \
|
||||
NSLock.m \
|
||||
NSLog.m \
|
||||
|
@ -275,6 +276,7 @@ NSObjectScripting.m \
|
|||
NSObject+NSComparisonMethods.m \
|
||||
NSOperation.m \
|
||||
NSOrderedSet.m \
|
||||
NSOrthography.m \
|
||||
NSPage.m \
|
||||
NSPathUtilities.m \
|
||||
NSPersonNameComponents.m \
|
||||
|
@ -460,6 +462,7 @@ NSKeyedArchiver.h \
|
|||
NSKeyValueCoding.h \
|
||||
NSKeyValueObserving.h \
|
||||
NSLengthFormatter.h \
|
||||
NSLinguisticTagger.h \
|
||||
NSLocale.h \
|
||||
NSLock.h \
|
||||
NSMapTable.h \
|
||||
|
@ -479,6 +482,7 @@ NSObject.h \
|
|||
NSObjectScripting.h \
|
||||
NSOperation.h \
|
||||
NSOrderedSet.h \
|
||||
NSOrthography.h \
|
||||
NSPathUtilities.h \
|
||||
NSPersonNameComponents.h \
|
||||
NSPersonNameComponentsFormatter.h \
|
||||
|
|
257
Source/NSLinguisticTagger.m
Normal file
257
Source/NSLinguisticTagger.m
Normal file
|
@ -0,0 +1,257 @@
|
|||
/* Implementation of class NSLinguisticTagger
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Sat Nov 2 21:37:50 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSLinguisticTagger.h>
|
||||
#include <Foundation/NSRange.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSOrthography.h>
|
||||
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeTokenType = @"NSLinguisticTagSchemeTokenType";
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeLexicalClass = @"NSLinguisticTagSchemeLexicalClass";
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeNameType = @"NSLinguisticTagSchemeNameType";
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeNameTypeOrLexicalClass = @"NSLinguisticTagSchemeNameTypeOrLexicalClass";
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeLemma = @"NSLinguisticTagSchemeLemma";
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeLanguage = @"NSLinguisticTagSchemeLanguage";
|
||||
NSLinguisticTagScheme const NSLinguisticTagSchemeScript = @"NSLinguisticTagSchemeScript";
|
||||
|
||||
/* Tags for NSLinguisticTagSchemeTokenType */
|
||||
NSLinguisticTag const NSLinguisticTagWord = @"NSLinguisticTagWord";
|
||||
NSLinguisticTag const NSLinguisticTagPunctuation = @"NSLinguisticTagPunctuation";
|
||||
NSLinguisticTag const NSLinguisticTagWhitespace = @"NSLinguisticTagWhitespae";
|
||||
NSLinguisticTag const NSLinguisticTagOther = @"NSLinguisticTagOther";
|
||||
|
||||
/* Tags for NSLinguisticTagSchemeLexicalClass */
|
||||
NSLinguisticTag const NSLinguisticTagNoun = @"NSLinguisticTagNoun";
|
||||
NSLinguisticTag const NSLinguisticTagVerb = @"NSLinguisticTagVerb";
|
||||
NSLinguisticTag const NSLinguisticTagAdjective = @"NSLinguisticTagAdjective";
|
||||
NSLinguisticTag const NSLinguisticTagAdverb = @"NSLinguisticTagAdverb";
|
||||
NSLinguisticTag const NSLinguisticTagPronoun = @"NSLinguisticTagPronoun";
|
||||
NSLinguisticTag const NSLinguisticTagDeterminer = @"NSLinguisticTagDeterminer";
|
||||
NSLinguisticTag const NSLinguisticTagParticle = @"NSLinguisticTagParticle";
|
||||
NSLinguisticTag const NSLinguisticTagPreposition = @"NSLinguisticTagPrepostion";
|
||||
NSLinguisticTag const NSLinguisticTagNumber = @"NSLinguisticTagNumber";
|
||||
NSLinguisticTag const NSLinguisticTagConjunction = @"NSLinguisticTagConjunction";
|
||||
NSLinguisticTag const NSLinguisticTagInterjection = @"NSLinguisticTagInterjection";
|
||||
NSLinguisticTag const NSLinguisticTagClassifier = @"NSLinguisticTagClassifier";
|
||||
NSLinguisticTag const NSLinguisticTagIdiom = @"NSLinguisticTagIdiom";
|
||||
NSLinguisticTag const NSLinguisticTagOtherWord = @"NSLinguisticTagOtherWord";
|
||||
NSLinguisticTag const NSLinguisticTagSentenceTerminator = @"NSLinguisticTagSentenceTerminator";
|
||||
NSLinguisticTag const NSLinguisticTagOpenQuote = @"NSLinguisticTagOpenQuote";
|
||||
NSLinguisticTag const NSLinguisticTagCloseQuote = @"NSLinguisticTagCloseQuote";
|
||||
NSLinguisticTag const NSLinguisticTagOpenParenthesis = @"NSLinguisticTagOpenParenthesis";
|
||||
NSLinguisticTag const NSLinguisticTagCloseParenthesis = @"NSLinguisticTagCloseParenthesis";
|
||||
NSLinguisticTag const NSLinguisticTagWordJoiner = @"NSLinguisticTagWordJoiner";
|
||||
NSLinguisticTag const NSLinguisticTagDash = @"NSLinguisticTagDash";
|
||||
NSLinguisticTag const NSLinguisticTagOtherPunctuation = @"NSLinguisticTagOtherPunctuation";
|
||||
NSLinguisticTag const NSLinguisticTagParagraphBreak = @"NSLinguisticTagParagraphBreak";
|
||||
NSLinguisticTag const NSLinguisticTagOtherWhitespace = @"NSLinguisticTagOtherWhitespace";
|
||||
|
||||
/* Tags for NSLinguisticTagSchemeNameType */
|
||||
NSLinguisticTag const NSLinguisticTagPersonalName = @"NSLinguisticTagPersonalName";
|
||||
NSLinguisticTag const NSLinguisticTagPlaceName = @"NSLinguisticTagPlaceName";
|
||||
NSLinguisticTag const NSLinguisticTagOrganizationName = @"NSLinguisticTagOrganizationName";
|
||||
|
||||
@implementation NSLinguisticTagger
|
||||
|
||||
- (instancetype) initWithTagSchemes: (NSArray *)tagSchemes
|
||||
options: (NSUInteger)opts
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
ASSIGNCOPY(_schemes, tagSchemes);
|
||||
_options = opts;
|
||||
_string = nil;
|
||||
_dominantLanguage = nil;
|
||||
_tokenArray = nil;
|
||||
_orthographyArray = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_schemes);
|
||||
RELEASE(_string);
|
||||
RELEASE(_dominantLanguage);
|
||||
RELEASE(_tokenArray);
|
||||
RELEASE(_orthographyArray);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *) tagSchemes
|
||||
{
|
||||
return _schemes;
|
||||
}
|
||||
|
||||
- (NSString *) string
|
||||
{
|
||||
return _string;
|
||||
}
|
||||
|
||||
- (void) setString: (NSString *)string
|
||||
{
|
||||
ASSIGNCOPY(_string, string);
|
||||
}
|
||||
|
||||
+ (NSArray *) availableTagSchemesForUnit: (NSLinguisticTaggerUnit)unit
|
||||
language: (NSString *)language
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSArray *) availableTagSchemesForLanguage: (NSString *)language
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) setOrthography: (NSOrthography *)orthography
|
||||
range: (NSRange)range
|
||||
{
|
||||
}
|
||||
|
||||
- (NSOrthography *) orthographyAtIndex: (NSUInteger)charIndex
|
||||
effectiveRange: (NSRangePointer)effectiveRange
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) stringEditedInRange: (NSRange)newRange
|
||||
changeInLength: (NSInteger)delta
|
||||
{
|
||||
}
|
||||
|
||||
- (NSRange) tokenRangeAtIndex: (NSUInteger)charIndex
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
{
|
||||
return NSMakeRange(0,0);
|
||||
}
|
||||
|
||||
- (NSRange) sentenceRangeForRange: (NSRange)range
|
||||
{
|
||||
return NSMakeRange(0,0);
|
||||
}
|
||||
|
||||
- (void) enumerateTagsInRange: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
usingBlock: (GSLinguisticTagRangeBoolBlock)block
|
||||
{
|
||||
}
|
||||
|
||||
- (NSLinguisticTag) tagAtIndex: (NSUInteger)charIndex
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
tokenRange: (NSRangePointer)tokenRange
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *) tagsInRange: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
tokenRanges: (NSArray **)tokenRanges
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) enumerateTagsInRange: (NSRange)range
|
||||
scheme: (NSLinguisticTagScheme)tagScheme
|
||||
options: (NSLinguisticTaggerOptions)opts
|
||||
usingBlock: (GSLinguisticTagRangeRangeBoolBlock)block
|
||||
{
|
||||
}
|
||||
|
||||
- (NSLinguisticTag) tagAtIndex: (NSUInteger)charIndex
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
tokenRange: (NSRangePointer)tokenRange
|
||||
sentenceRange: (NSRangePointer)sentenceRange
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *) tagsInRange: (NSRange)range
|
||||
scheme: (NSString *)tagScheme
|
||||
options: (NSLinguisticTaggerOptions)opts
|
||||
tokenRanges: (NSArray **)tokenRanges
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *) dominantLanguage
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSString *) dominantLanguageForString: (NSString *)string
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSLinguisticTag) tagForString: (NSString *)string
|
||||
atIndex: (NSUInteger)charIndex
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
orthography: (NSOrthography *)orthography
|
||||
tokenRange: (NSRangePointer)tokenRange
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSArray *)tagsForString: (NSString *)string
|
||||
range: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
orthography: (NSOrthography *)orthography
|
||||
tokenRanges: (NSArray **)tokenRanges
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void) enumerateTagsForString: (NSString *)string
|
||||
range: (NSRange)range
|
||||
unit: (NSLinguisticTaggerUnit)unit
|
||||
scheme: (NSLinguisticTagScheme)scheme
|
||||
options: (NSLinguisticTaggerOptions)options
|
||||
orthography: (NSOrthography *)orthography
|
||||
usingBlock: (GSLinguisticTagRangeBoolBlock)block
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *) possibleTagsAtIndex: (NSUInteger)charIndex
|
||||
scheme: (NSString *)tagScheme
|
||||
tokenRange: (NSRangePointer)tokenRange
|
||||
sentenceRange: (NSRangePointer)sentenceRange
|
||||
scores: (NSArray **)scores
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
|
112
Source/NSOrthography.m
Normal file
112
Source/NSOrthography.m
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* Implementation of class NSOrthography
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento <greg.casamento@gmail.com>
|
||||
Date: Tue Nov 5 03:43:39 EST 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSOrthography.h>
|
||||
|
||||
@implementation NSOrthography
|
||||
|
||||
- (instancetype) initWithDominantScript: (NSString *)script
|
||||
languageMap: (NSDictionary *)map
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
ASSIGNCOPY(_dominantScript, script);
|
||||
ASSIGNCOPY(_languageMap, map);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (oneway void) release
|
||||
{
|
||||
RELEASE(_dominantScript);
|
||||
RELEASE(_languageMap);
|
||||
[super release];
|
||||
}
|
||||
|
||||
- (NSString *) dominantScript
|
||||
{
|
||||
return _dominantScript;
|
||||
}
|
||||
|
||||
- (NSDictionary *) languationMap
|
||||
{
|
||||
return _languageMap;
|
||||
}
|
||||
|
||||
- (NSArray *) languagesForScript: (NSString *)script
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *) dominantLanguageForScript: (NSString *)script
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *) dominantLanguage
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *) allScripts
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *) allLanguages
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype) defaultOrthographyForLanguage: (NSString *)language
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype) orthographyWithDominantScript: (NSString *)script languageMap: (NSDictionary *)map
|
||||
{
|
||||
NSOrthography *result = [[NSOrthography alloc] initWithDominantScript: script
|
||||
languageMap: map];
|
||||
AUTORELEASE(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
}
|
||||
|
||||
- (instancetype) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
return [[[self class] allocWithZone: zone]
|
||||
initWithDominantScript: _dominantScript
|
||||
languageMap: _languageMap];
|
||||
}
|
||||
@end
|
||||
|
Loading…
Reference in a new issue