|
| 1 | +from analyzer_interface import (AnalyzerInput, AnalyzerInterface, |
| 2 | + AnalyzerOutput, InputColumn, OutputColumn) |
| 3 | + |
| 4 | +from .main import (MESSAGE__ID, MESSAGE__TEXT, |
| 5 | + NGRAM__ID, NGRAM__LENGTH, |
| 6 | + NGRAM__WORDS, MESSAGE__NGRAM_COUNT, AUTHOR__ID, analyze_ngrams) |
| 7 | + |
| 8 | +interface = AnalyzerInterface( |
| 9 | + id="ngrams", |
| 10 | + version="0.1.0", |
| 11 | + name="ngrams", |
| 12 | + short_description="Extracts n-grams from text data", |
| 13 | + long_description=""" |
| 14 | +The n-gram analysis extract n-grams (sequences of n words) from the text data |
| 15 | +in the input and counts the occurrences of each n-gram in each message, linking |
| 16 | +the message author to the ngram frequency. |
| 17 | +
|
| 18 | +The result can be used to see if certain word sequences are more common in |
| 19 | +the corpus of text, and whether certain authors use these sequences more often. |
| 20 | + """, |
| 21 | + input=AnalyzerInput(columns=[ |
| 22 | + InputColumn( |
| 23 | + name=AUTHOR__ID, |
| 24 | + data_type="identifier", |
| 25 | + description="The unique identifier of the author of the message", |
| 26 | + name_hints=["author", "user", "poster", "username", |
| 27 | + "screen name", "user name", "name", "email"] |
| 28 | + ), |
| 29 | + InputColumn( |
| 30 | + name=MESSAGE__ID, |
| 31 | + data_type="identifier", |
| 32 | + description="The unique identifier of the message", |
| 33 | + name_hints=["post", "message", "comment", |
| 34 | + "text", "retweet id", "tweet"] |
| 35 | + ), |
| 36 | + InputColumn( |
| 37 | + name=MESSAGE__TEXT, |
| 38 | + data_type="text", |
| 39 | + description="The text content of the message", |
| 40 | + name_hints=["message", "text", "comment", |
| 41 | + "post", "body", "content", "tweet"] |
| 42 | + ) |
| 43 | + ]), |
| 44 | + outputs=[ |
| 45 | + AnalyzerOutput( |
| 46 | + id="message_ngrams", |
| 47 | + name="N-gram count per message", |
| 48 | + columns=[ |
| 49 | + OutputColumn(name=MESSAGE__ID, data_type="identifier"), |
| 50 | + OutputColumn(name=NGRAM__ID, data_type="identifier"), |
| 51 | + OutputColumn(name=MESSAGE__NGRAM_COUNT, data_type="integer") |
| 52 | + ] |
| 53 | + ), |
| 54 | + AnalyzerOutput( |
| 55 | + id="ngrams", |
| 56 | + name="N-gram definitions", |
| 57 | + description="The word compositions of each unique n-gram", |
| 58 | + columns=[ |
| 59 | + OutputColumn(name=NGRAM__ID, data_type="identifier"), |
| 60 | + OutputColumn(name=NGRAM__WORDS, data_type="text"), |
| 61 | + OutputColumn(name=NGRAM__LENGTH, data_type="integer") |
| 62 | + ] |
| 63 | + ), |
| 64 | + AnalyzerOutput( |
| 65 | + id="message_authors", |
| 66 | + name="Message authorship", |
| 67 | + description="Message authorship", |
| 68 | + columns=[ |
| 69 | + OutputColumn(name=AUTHOR__ID, data_type="identifier"), |
| 70 | + OutputColumn(name=MESSAGE__ID, data_type="identifier") |
| 71 | + ] |
| 72 | + ) |
| 73 | + ], |
| 74 | + entry_point=analyze_ngrams |
| 75 | +) |
0 commit comments