Closed p-acharya closed 3 months ago
Nvm I got it! Just wrote a quick script:
from neosca.ns_sca.ns_sca import Ns_SCA
def run_sca_on_text(text):
# Create an instance of Ns_SCA with is_stdout set to True to print the output
analyzer = Ns_SCA(is_stdout=True, oformat_freq="json")
# Run the SCA on the input text
analyzer.run_on_text(text)
sample_1 =
"""
Scores of properties are under extreme fire threat as a huge blaze
continues to advance through Sydney's north-western suburbs. Fires
have also shut down the major road and rail links between Sydney and
Gosford.
The promotional stop in Sydney was everything to be expected for a
Hollywood blockbuster - phalanxes of photographers, a stretch limo to
a hotel across the Quay - but with one difference. A line-up of
masseurs was waiting to take the media in hand. Never has the term
'massaging the media' seemed so accurate.
"""
# Test the function with a sample text
run_sca_on_text(sample_1)
That's great! Here is a different way, but whatever works as long as you get the dictionary.
from neosca.ns_sca.ns_sca import Ns_SCA, Ns_SCA_Counter
def analyze_text(text: str) -> dict[str, float]:
sca.run_on_text(text)
counter: Ns_SCA_Counter = sca.counters[0]
name_value_map: dict[str, str] = counter.get_all_values(precision=4)
name_value_map.pop("Filepath")
ret: dict[str, float] = {k: float(v) for k, v in name_value_map.items()}
return ret
def analyze_file(filepath: str) -> dict[str, float]:
counter: Ns_SCA_Counter = sca.run_on_file_or_subfiles(filepath)
name_value_map: dict[str, str] = counter.get_all_values(precision=4)
name_value_map.pop("Filepath")
ret: dict[str, float] = {k: float(v) for k, v in name_value_map.items()}
return ret
sca = Ns_SCA()
sample_1 = """
Scores of properties are under extreme fire threat as a huge
blaze continues to advance through Sydney's north-western suburbs. Fires have
also shut down the major road and rail links between Sydney and Gosford.
The promotional stop in Sydney was everything to be expected for a Hollywood
blockbuster - phalanxes of photographers, a stretch limo to a hotel across the
Quay - but with one difference. A line-up of masseuses was waiting to take the
media in hand. Never has the term "massaging the media" seemed so accurate.
"""
analyze_text(sample_1)
Here is the basic command line usage:
python -m neosca sca --text 'This is a test.'
python -m neosca sca filepath.txt
For descriptions about additional options, use:
python -m neosca --help
python -m neosca sca --help
Thanks a lot for updating this to use Stanza.
Would it be possible to update the README on how to use the command line tool? Also, how can I replicate the following script using neosca?
This is taken from the original L2SCA code
so that I can do this:
i.e. how do i get the same measurements dictionary using neosca?