Skip to content

Commit

Permalink
Обновлена версия библиотеки для работы с битами
Browse files Browse the repository at this point in the history
  • Loading branch information
demidko committed Aug 6, 2022
1 parent 73f6e5d commit 7fbd388
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ plugins {
`maven-publish`
}
dependencies {
api("com.github.demidko:bits:2021.11.17")
api("com.github.demidko:bits:2022.08.06")
api("com.github.demidko:aot-bytecode:2021.10.29")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
testImplementation("org.hamcrest:hamcrest:2.2")
}
tasks.test {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 13 additions & 16 deletions src/main/java/com/github/demidko/aot/WordformMeaning.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
package com.github.demidko.aot;

import static com.github.demidko.aot.AotReader.readLemmas;
import static com.github.demidko.aot.AotReader.readMorph;
import static com.github.demidko.aot.AotReader.readRefs;
import static com.github.demidko.aot.AotReader.readStrings;
import static com.github.demidko.aot.ByteBlock.readBlockFrom;
import static com.github.demidko.aot.PartOfSpeech.partOfSpeech;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Objects.hash;

import com.github.demidko.bits.BitReader;
import com.github.demidko.bits.BitWriter;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -20,6 +11,13 @@
import java.util.Map;
import java.util.zip.GZIPInputStream;

import static com.github.demidko.aot.AotReader.*;
import static com.github.demidko.aot.ByteBlock.readBlockFrom;
import static com.github.demidko.aot.PartOfSpeech.partOfSpeech;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Objects.hash;

/**
* Словоформа одного определенного смысла. Зачем нужна эта абстракция вместо простого слова? Например, у слова "замок"
* может быть три основных смысла: 1. Замок как строение. 2. Замок как устройство для запора дверей. 3. Замок, как форма
Expand All @@ -46,7 +44,7 @@ public class WordformMeaning {

static {
try (DataInputStream file =
new DataInputStream(new GZIPInputStream(WordformMeaning.class.getResourceAsStream("/mrd.gz")))
new DataInputStream(new GZIPInputStream(WordformMeaning.class.getResourceAsStream("/mrd.gz")))
) {
allMorphologyTags = readMorph(readBlockFrom(file));
allFlexionStrings = readStrings(readBlockFrom(file));
Expand Down Expand Up @@ -108,7 +106,6 @@ public static List<WordformMeaning> lookupForMeanings(String w) throws IOExcepti
* @return словоформ смысла
*/
public static WordformMeaning lookupForMeaning(long id) throws IOException {

BitReader reader = new BitReader(id);
int lemmaId = reader.readInt();
int flexionIndex = reader.readInt();
Expand All @@ -122,10 +119,10 @@ public static WordformMeaning lookupForMeaning(long id) throws IOException {
* примитив long.
*/
public long getId() {
BitWriter w = new BitWriter();
w.writeInt(lemmaId);
w.writeInt(transformationIndex);
return w.toLong();
return new BitWriter()
.writeInt(lemmaId)
.writeInt(transformationIndex)
.toLong();
}

/**
Expand Down

0 comments on commit 7fbd388

Please sign in to comment.