mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Add NSOrthography and NSLinguisticTagger
This commit is contained in:
parent
1fe061b1dc
commit
30162a9a1e
6 changed files with 344 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>
|
||||
|
|
231
Headers/Foundation/NSLinguisticTagger.h
Normal file
231
Headers/Foundation/NSLinguisticTagger.h
Normal file
|
@ -0,0 +1,231 @@
|
|||
/* 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
|
||||
|
||||
- (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 */
|
||||
|
47
Headers/Foundation/NSOrthography.h
Normal file
47
Headers/Foundation/NSOrthography.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* 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_0, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@interface NSOrthography : NSObject
|
||||
|
||||
@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 \
|
||||
|
|
30
Source/NSLinguisticTagger.m
Normal file
30
Source/NSLinguisticTagger.m
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* 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>
|
||||
|
||||
@implementation NSLinguisticTagger
|
||||
|
||||
@end
|
||||
|
30
Source/NSOrthography.m
Normal file
30
Source/NSOrthography.m
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Implementation 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.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSOrthography.h>
|
||||
|
||||
@implementation NSOrthography
|
||||
|
||||
@end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue