drama-js
Version:
A JavaScript library to detect drama in text using sentiment analysis
123 lines (122 loc) • 3.32 kB
TypeScript
/**
* Drama detection thresholds
*/
export interface DramaThresholds {
/**
* Minimum absolute score to consider text dramatic (default: 2.0)
*/
scoreThreshold?: number;
/**
* Minimum comparative score to consider text dramatic (default: 0.3)
*/
comparativeThreshold?: number;
/**
* Minimum number of negative words to consider text dramatic (default: 2)
*/
negativeWordsThreshold?: number;
}
/**
* Result of drama analysis
*/
export interface DramaAnalysisResult {
/**
* Original text that was analyzed
*/
text: string;
/**
* Whether the text contains drama
*/
hasDrama: boolean;
/**
* Drama score (higher absolute value means more dramatic)
*/
score: number;
/**
* Comparative score (normalized by text length)
*/
comparative: number;
/**
* Number of positive words found
*/
positiveCount: number;
/**
* Number of negative words found
*/
negativeCount: number;
/**
* List of positive words found
*/
positiveWords: string[];
/**
* List of negative words found
*/
negativeWords: string[];
/**
* Drama intensity level
*/
dramaLevel: 'none' | 'mild' | 'moderate' | 'high' | 'extreme';
}
/**
* Drama analyzer class
*/
export declare class DramaAnalyzer {
private sentimentAnalyzer;
private thresholds;
/**
* Create a new DramaAnalyzer instance
* @param options Custom thresholds for drama detection
*/
constructor(options?: DramaThresholds);
/**
* Extend the sentiment lexicon with drama-specific words
*/
/**
* Analyze text for drama
* @param text Text to analyze
* @returns Drama analysis result
*/
analyze(text: string): DramaAnalysisResult;
/**
* Check if text contains drama
* @param text Text to check
* @returns True if the text contains drama, false otherwise
*/
hasDrama(text: string): boolean;
/**
* Get the drama level of the text
* @param text Text to analyze
* @returns Drama level ('none', 'mild', 'moderate', 'high', 'extreme')
*/
getDramaLevel(text: string): DramaAnalysisResult['dramaLevel'];
/**
* Update drama detection thresholds
* @param thresholds New thresholds
*/
updateThresholds(thresholds: DramaThresholds): void;
}
/**
* Analyze text for drama using default settings
* @param text Text to analyze
* @returns Drama analysis result
*/
export declare function analyzeDrama(text: string): DramaAnalysisResult;
/**
* Check if text contains drama using default settings
* @param text Text to check
* @returns True if the text contains drama, false otherwise
*/
export declare function hasDrama(text: string): boolean;
/**
* Get the drama level of the text using default settings
* @param text Text to analyze
* @returns Drama level ('none', 'mild', 'moderate', 'high', 'extreme')
*/
export declare function getDramaLevel(text: string): DramaAnalysisResult['dramaLevel'];
declare const _default: {
DramaAnalyzer: typeof DramaAnalyzer;
analyzeDrama: typeof analyzeDrama;
hasDrama: typeof hasDrama;
getDramaLevel: typeof getDramaLevel;
defaultAnalyzer: DramaAnalyzer;
};
export default _default;