# analyze-desumasu-dearu

> 文の敬体(ですます調)、常体(である調)を解析

Latest version **6.0.1** (published 2026-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install analyze-desumasu-dearu
pnpm add analyze-desumasu-dearu
yarn add analyze-desumasu-dearu
bun add analyze-desumasu-dearu
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 6.0.1 |
| Published | 2026-04-07 |
| First published | 2015-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | azu |
| Maintainers | azu, shirayu, takahashim, textlint-user, hata6502 |
| Keywords | japanese, analyze |

## Links

- npm: https://www.npmjs.com/package/analyze-desumasu-dearu
- Repository: https://github.com/textlint-ja/analyze-desumasu-dearu
- Issues: https://github.com/textlint-ja/analyze-desumasu-dearu/issues
- npm.io page: https://npm.io/package/analyze-desumasu-dearu

## Recent versions

- 6.0.1 (latest) — 2026-04-07
- 6.0.0 — 2025-01-16
- 5.0.2 — 2025-01-16
- 5.0.1 — 2021-12-10
- 5.0.0 — 2021-04-24
- 4.0.1 — 2020-07-25
- 4.0.0 — 2018-09-27
- 3.1.0 — 2016-05-10
- 3.0.4 — 2016-05-06
- 3.0.3 — 2016-05-05
- 3.0.2 — 2016-05-05
- 3.0.1 — 2016-05-05
- 3.0.0 — 2016-05-05
- 2.1.5 — 2016-02-28
- 2.1.4 — 2015-11-10
- … 7 more at https://npm.io/package/analyze-desumasu-dearu/versions

## README

# analyze-desumasu-dearu [![Actions Status: test](https://github.com/textlint-ja/analyze-desumasu-dearu/workflows/test/badge.svg)](https://github.com/textlint-ja/analyze-desumasu-dearu/actions?query=workflow%3A"test")

文の敬体(ですます調)、常体(である調)を解析するライブラリ

形態素解析器として[kuromoji.js](https://github.com/takuyaa/kuromoji.js "kuromoji.js")を利用しています。

## Installation

    npm install analyze-desumasu-dearu

## Usage

```js
"use strict";
import { isDearu, isDesumasu, analyze, analyzeDearu, analyzeDesumasu } from "analyze-desumasu-dearu";
analyze(text).then((results) => {
    console.log("==である==");
    console.log(results.filter(isDearu));
    console.log("==ですます==");
    console.log(results.filter(isDesumasu));
});
```

Result to

```
==である==
[ { type: '特殊・ダ',
    value: 'であった',
    surface: 'で',
    index: 7,
    token:
     { word_id: 305030,
       word_type: 'KNOWN',
       word_position: 8,
       surface_form: 'で',
       pos: '助動詞',
       pos_detail_1: '*',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '特殊・ダ',
       conjugated_form: '連用形',
       basic_form: 'だ',
       reading: 'デ',
       pronunciation: 'デ' } },
  { type: '特殊・ダ',
    value: 'だが、',
    surface: 'だ',
    index: 12,
    token:
     { word_id: 305000,
       word_type: 'KNOWN',
       word_position: 13,
       surface_form: 'だ',
       pos: '助動詞',
       pos_detail_1: '*',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '特殊・ダ',
       conjugated_form: '基本形',
       basic_form: 'だ',
       reading: 'ダ',
       pronunciation: 'ダ' } } ]
==ですます==
[ { type: '特殊・デス',
    value: 'です。',
    surface: 'です',
    index: 21,
    token:
     { word_id: 305080,
       word_type: 'KNOWN',
       word_position: 22,
       surface_form: 'です',
       pos: '助動詞',
       pos_detail_1: '*',
       pos_detail_2: '*',
       pos_detail_3: '*',
       conjugated_type: '特殊・デス',
       conjugated_form: '基本形',
       basic_form: 'です',
       reading: 'デス',
       pronunciation: 'デス' } } ]
```

### `analyze(text, options): Promise.<AnalyzedResultObject[]>`

`text`から敬体(ですます調)と常体(である調)を取り出した結果を返します

-   `options`
-   `ignoreConjunction`: 無視オプションを指定できます

```js
/**
 * デフォルトのオプション値
 * @type {{ignoreConjunction: boolean}}
 */
const defaultOptions = {
    // 接続的な使い方を無視する
    // e.g.) 今日はいい天気であるが明日はどうなるかは分からない。
    ignoreConjunction: false
};
```

```js
// AnalyzedResultObjectの配列
[
    {
        // 文体を含んだ内容 - なんとなくいい感じの部分までを繋げた文字列
        // e.g.) "です。"
        value: string,
        // 該当するtoken文字
        // e.g.) "です"
        surface: string,
        // textの先頭からの位置(start with 0)
        index: number,
        // kuromoji.jsのtokenオブジェクトそのもの https://github.com/takuyaa/kuromoji.js#api
        // surfaceやindexはこのtokenから算出
        token: AnalyzedToken
    }
];
```

### `analyzeDesumasu(text, options): Promise.<AnalyzedResultObject[]>`

`text`に含まれる文の敬体(ですます調)を解析して、AnalyzedResultObject の配列を返します。

内部的には`analyze()`を使っています。

```js
/**
 * `text` の敬体(ですます調)について解析し、敬体(ですます調)のトークン情報を返します。
 * @param {string} text
 * @param {Object} options
 * @return {Promise.<AnalyzedResultObject[]>}
 */
export function analyzeDesumasu(text, options = defaultOptions) {
    return analyze(text, options).then((results) => results.filter(isDesumasu));
}
```

### `analyzeDearu(text, options): Promise.<AnalyzedResultObject[]>`

常体(である調)を解析して AnalyzedResultObject の配列を返します

-   `options`
-   `ignoreConjunction`: 無視オプションを指定できます。

```js
/**
 * デフォルトのオプション値
 * @type {{ignoreConjunction: boolean}}
 */
const defaultOptions = {
    // 接続的なであるの使い方を無視する
    // e.g.) 今日はいい天気であるが明日はどうなるかは分からない。
    ignoreConjunction: false
};
```

内部的には`analyze()`を使っています。

```js
/**
 * `text` の常体(である調)について解析し、常体(である調)のトークン情報を返します。
 * @param {string} text
 * @param {Object} options
 * @return {Promise.<AnalyzedResultObject[]>}
 */
export function analyzeDearu(text, options = defaultOptions) {
    return analyze(text, options).then((results) => results.filter(isDearu));
}
```

## UseCase

以下のツールなどで利用しています。

- [textlint-ja/textlint-rule-no-mix-dearu-desumasu: textlint rule that check no mix である and ですます.](https://github.com/textlint-ja/textlint-rule-no-mix-dearu-desumasu)

## Tests

    npm test

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## License

MIT

## Acknowledge

Thank for [RedPen](http://redpen.cc/ "RedPen").

---
_Source: https://npm.io/package/analyze-desumasu-dearu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
