@@ -15,18 +15,22 @@ export type Midashi = string;
1515 * usedItemGroup.forEach
1616 */
1717export class ItemGroup {
18- constructor ( public items : SudachiSynonyms [ ] ) {
19-
20- }
18+ constructor ( public items : SudachiSynonyms [ ] ) { }
2119
2220 getItem ( midashi : string ) : SudachiSynonyms | null {
23- return this . items . find ( item => item . midashi === midashi ) ?? null
21+ return this . items . find ( ( item ) => item . midashi === midashi ) ?? null ;
2422 }
2523
26- usedItems ( usedItemSet : Set < SudachiSynonyms > , { allowAlphabet, allowNumber, allows } : { allowAlphabet : boolean ; allowNumber : boolean ; allows : string [ ] } ) : SudachiSynonyms [ ] {
24+ usedItems (
25+ usedItemSet : Set < SudachiSynonyms > ,
26+ { allowAlphabet, allowNumber, allows } : { allowAlphabet : boolean ; allowNumber : boolean ; allows : string [ ] }
27+ ) : SudachiSynonyms [ ] {
2728 // sort by used
28- return Array . from ( usedItemSet . values ( ) ) . filter ( item => {
29- if ( allowAlphabet && ( item . hyoukiYure === "アルファベット表記" || item . ryakusyou === "略語・略称/アルファベット" ) ) {
29+ return Array . from ( usedItemSet . values ( ) ) . filter ( ( item ) => {
30+ if (
31+ allowAlphabet &&
32+ ( item . hyoukiYure === "アルファベット表記" || item . ryakusyou === "略語・略称/アルファベット" )
33+ ) {
3034 // アルファベット表記
3135 // blog <-> ブログ
3236 // 略語・略称/アルファベット
@@ -61,7 +65,10 @@ $ npm install sudachi-synonyms-dictionary
6165` ) ;
6266 }
6367} ;
64- export type IndexType = { keyItemGroupMap : Map < Midashi , ItemGroup [ ] > ; SudachiSynonymsItemGroup : Map < SudachiSynonyms , ItemGroup > ; } ;
68+ export type IndexType = {
69+ keyItemGroupMap : Map < Midashi , ItemGroup [ ] > ;
70+ SudachiSynonymsItemGroup : Map < SudachiSynonyms , ItemGroup > ;
71+ } ;
6572let _ret : IndexType | null = null ;
6673export const createIndex = async ( ) : Promise < IndexType > => {
6774 if ( _ret ) {
@@ -71,19 +78,21 @@ export const createIndex = async (): Promise<IndexType> => {
7178 const keyItemGroupMap : Map < Midashi , ItemGroup [ ] > = new Map ( ) ;
7279 const SudachiSynonymsItemGroup : Map < SudachiSynonyms , ItemGroup > = new Map ( ) ;
7380 const SynonymsDictionary = await fetchDictionary ( ) ;
74- SynonymsDictionary . forEach ( group => {
81+ SynonymsDictionary . forEach ( ( group ) => {
7582 const groupByVocabularyNumber = group . items . reduce ( ( res , item ) => {
7683 res [ item . vocabularyNumber ! ] = ( res [ item . vocabularyNumber ! ] || [ ] ) . concat ( item ) ;
7784 return res ;
7885 } , { } as { [ index : string ] : SudachiSynonyms [ ] } ) ;
79- const itemGroups = Object . values ( groupByVocabularyNumber ) . filter ( items => {
80- return items . length > 1 ;
81- } ) . map ( items => {
82- return new ItemGroup ( items ) ;
83- } ) ;
86+ const itemGroups = Object . values ( groupByVocabularyNumber )
87+ . filter ( ( items ) => {
88+ return items . length > 1 ;
89+ } )
90+ . map ( ( items ) => {
91+ return new ItemGroup ( items ) ;
92+ } ) ;
8493 // register key with itemGroup
85- itemGroups . forEach ( itemGroup => {
86- itemGroup . items . forEach ( item => {
94+ itemGroups . forEach ( ( itemGroup ) => {
95+ itemGroup . items . forEach ( ( item ) => {
8796 const oldItemGroup = keyItemGroupMap . get ( item . midashi ) || [ ] ;
8897 keyItemGroupMap . set ( item . midashi , oldItemGroup . concat ( itemGroup ) ) ;
8998 SudachiSynonymsItemGroup . set ( item , itemGroup ) ;
0 commit comments