Skip to main content

An implementation of C-value and NC-value methods

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ncnc-1.0.1.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ncnc-1.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file ncnc-1.0.1.tar.gz.

File metadata

  • Download URL: ncnc-1.0.1.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for ncnc-1.0.1.tar.gz
Algorithm Hash digest
SHA256 69c23da368b6818507bc2a6c361efd072c34310e5b495e580750a549de92da1c
MD5 1e84e138e612e422bc8e0c7a1f3a851c
BLAKE2b-256 5912181f3e6a74ff1356126b60b17fe30a4ae80807412f7004628b68a46a42a9

See more details on using hashes here.

File details

Details for the file ncnc-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ncnc-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for ncnc-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 029b3135e5968331364cd44ac4a2f993a399df39b3c9edbfa7c40059b40e8fa1
MD5 81d1562ee0b19e5f262b18622a734ec7
BLAKE2b-256 dbd720447591805d3b5495faf0ea77061ef5a37d8c701e2d288c726c641cda70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page