Skip to main content

ncnc

test

This is an implementation of C-value and NC-value methods proposed in the following paper:

  • Automatic Recognition of Multi-Word Terms: the C-value/NC-value Method

Installation

$ pip install ncnc

Usage

C-value

First, prepare a DataFrame object which has the total frequency of each n-gram in a corpus. The names of the column and index should be f(a) and ngram, respectivey. The following code shows an example.

import pandas as pd


dict = {
    "adenoid cystic basal cell carcinoma": 5
    "cystic basal cell carcinoma": 11,
    "ulcerated basal cell carcinoma": 7,
    "recurrent basal cell carcinoma": 5,
    "circumscribed basal cell carcinoma": 3,
    "basal cell carcinoma": 984,
}
df = pd.DataFrame.from_dict(dict, orient="index", columns=["f(a)"]
df.index.name = "ngram"

Then, give the DataFrame object to calc_c_value().

from ncnc.c_value import calc_c_value


df = calc_c_value(df)

Now, you can see a C-value for each n-gram like this:

df = df.sort_values(by="c-value", ascending=False)
print(df.loc[:, ["f(a)", "c-value"]])

The results are as follows:

                                     f(a)      c-value
ngram
basal cell carcinoma                  984  1551.361296
ulcerated basal cell carcinoma          7    14.000000
cystic basal cell carcinoma            11    12.000000
adenoid cystic basal cell carcinoma     5    11.609640
recurrent basal cell carcinoma          5    10.000000
circumscribed basal cell carcinoma      3     6.000000

NC-value

You can also calculate a NC-value for each n-gram like this:

from ncnc.nc_value import calc_nc_value


df = calc_nc_value(df)
df = df.sort_values(by="nc-value", ascending=False)
print(df.loc[:, ["f(a)", "c-value", "nc-value"]])

Note that the input of calc_nc_value() is the output of calc_c_value(). The NC-values can be calculated after calculating the C-values.

Also note that we use all part-of-speech elements as context words, whereas the original paper used only nouns, adjectives, and verbs.

The results are as follows:

                                     f(a)      c-value     nc-value
ngram
basal cell carcinoma                  984  1551.361296  1242.122370
ulcerated basal cell carcinoma          7    14.000000    11.200000
cystic basal cell carcinoma            11    12.000000     9.766667
adenoid cystic basal cell carcinoma     5    11.609640     9.287712
recurrent basal cell carcinoma          5    10.000000     8.000000
circumscribed basal cell carcinoma      3     6.000000     4.800000

Metadata

Release files for ncnc 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ncnc 1.0.1
File Size Uploaded Provenance Actions
ncnc-1.0.1.tar.gz 33.6 kB Without provenance Details for ncnc-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ncnc 1.0.1
File Interpreter ABI Platform Actions
ncnc-1.0.1-py3-none-any.whl Python 3 none any Details for ncnc-1.0.1-py3-none-any.whl

Total release size: 38.6 kB

Release files / ncnc-1.0.1.tar.gz

Download URL ncnc-1.0.1.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
69c23da368b6818507bc2a6c361efd072c34310e5b495e580750a549de92da1c
BLAKE2b-256 checksum
How to use checksums
5912181f3e6a74ff1356126b60b17fe30a4ae80807412f7004628b68a46a42a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ncnc-1.0.1-py3-none-any.whl

Download URL ncnc-1.0.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
029b3135e5968331364cd44ac4a2f993a399df39b3c9edbfa7c40059b40e8fa1
BLAKE2b-256 checksum
How to use checksums
dbd720447591805d3b5495faf0ea77061ef5a37d8c701e2d288c726c641cda70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ncnc 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page