kandi background
Explore Kits

ET | Unity3D Client And C# Server Framework | Game Engine library

 by   egametang C# Version: Current License: MIT

 by   egametang C# Version: Current License: MIT

Download this library from

kandi X-RAY | ET Summary

ET is a C# library typically used in Gaming, Game Engine, Unity, Framework applications. ET has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Unity3D Client And C# Server Framework
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • ET has a medium active ecosystem.
  • It has 4771 star(s) with 1809 fork(s). There are 464 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 19 open issues and 72 have been closed. On average issues are closed in 31 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of ET is current.
ET Support
Best in #Game Engine
Average in #Game Engine
ET Support
Best in #Game Engine
Average in #Game Engine

quality kandi Quality

  • ET has 0 bugs and 0 code smells.
ET Quality
Best in #Game Engine
Average in #Game Engine
ET Quality
Best in #Game Engine
Average in #Game Engine

securitySecurity

  • ET has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ET code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
ET Security
Best in #Game Engine
Average in #Game Engine
ET Security
Best in #Game Engine
Average in #Game Engine

license License

  • ET is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
ET License
Best in #Game Engine
Average in #Game Engine
ET License
Best in #Game Engine
Average in #Game Engine

buildReuse

  • ET releases are not available. You will need to build from source code and install.
  • Installation instructions are not available. Examples and code snippets are available.
ET Reuse
Best in #Game Engine
Average in #Game Engine
ET Reuse
Best in #Game Engine
Average in #Game Engine
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

ET Key Features

Unity3D Client And C# Server Framework

3.跨平台的分布式服务端

copy iconCopydownload iconDownload
./Run.sh Config/StartConfig/192.168.12.188.txt 

4.提供协程支持

copy iconCopydownload iconDownload
// 发送C2R_Ping并且等待响应消息R2C_Ping
R2C_Ping pong = await session.Call(new C2R_Ping()) as R2C_Ping;
Log.Debug("收到R2C_Ping");

// 向mongodb查询一个id为1的Player,并且等待返回
Player player = await Game.Scene.GetComponent<DBProxyComponent>().Query<Player>(1);
Log.Debug($"打印player name: {player.Name}")

When replacing medians in an unknown category get NA in R

copy iconCopydownload iconDownload
> 7 > NA
[1] NA
library(dplyr)
d1 %>% 
   group_by(across(-wer)) %>% 
   summarise(wer = median(wer), .groups = "drop") %>% 
   right_join(d2, by = c("et", "gg", "hj", "ggh"), suffix = c("", ".y")) %>% 
   mutate(wer = ifelse(wer >= wer.y & !is.na(wer), wer, wer.y), .keep = "unused")
# A tibble: 2 × 5
  et    gg    hj    ggh     wer
  <chr> <chr> <chr> <chr> <dbl>
1 s     d     f     h        34
2 s     d     f     f         7
-----------------------
> 7 > NA
[1] NA
library(dplyr)
d1 %>% 
   group_by(across(-wer)) %>% 
   summarise(wer = median(wer), .groups = "drop") %>% 
   right_join(d2, by = c("et", "gg", "hj", "ggh"), suffix = c("", ".y")) %>% 
   mutate(wer = ifelse(wer >= wer.y & !is.na(wer), wer, wer.y), .keep = "unused")
# A tibble: 2 × 5
  et    gg    hj    ggh     wer
  <chr> <chr> <chr> <chr> <dbl>
1 s     d     f     h        34
2 s     d     f     f         7

Is this a bug in ruby Regexp? How to guard against &quot;infinite loop&quot; from regex match without using Timeout?

copy iconCopydownload iconDownload
# Test - Fail  [a-zA-Z\W]
puts "Hello World!";
regex = /(Si.ges[a-zA-Z\W]*avec\W*fonction\W*m.moires)/ui;
text = "xation de 2 sièges-enfants sur la banquette AR),Pack \"Assistance\",Keyless Access avec alarme : Système de verrouillage/déverrouillage et de démarrage sans clé,Park Assist: Système d'assistance au stationnement en créneauet et en bataille,Rear Assist: Caméra de recul avec visualisation de la zone situ";
res = text.match(regex);
puts "Done";

Creating nested columns in python dataframe

copy iconCopydownload iconDownload
import pandas as pd

# I assume that you can read raw data named test.csv by pandas and
# set header = None cause you mentioned the Test data without any headers, so:
df = pd.read_csv("test.csv", header = None)

# Then define preferred Columns! 
MyColumns = pd.MultiIndex.from_tuples([("Models" , ""),
                                       ("Accuracy without normalization" , ""),
                                       ("Accuracy with normalization" , "zscore"),
                                       ("Accuracy with normalization" , "minmax"),
                                       ("Accuracy with normalization" , "maxabs"),
                                       ("Accuracy with normalization" , "robust")])

# Create new DataFrame with specified Columns, after this you should pass values 
New_DataFrame = pd.DataFrame(df , columns = MyColumns)

# a loop for passing values
for item in range(len(MyColumns)):
    New_DataFrame.loc[: , MyColumns[item]] = df.iloc[: , item]
New_DataFrame.set_index(New_DataFrame.columns[0][0] , inplace=True)
New_DataFrame
-----------------------
import pandas as pd

# I assume that you can read raw data named test.csv by pandas and
# set header = None cause you mentioned the Test data without any headers, so:
df = pd.read_csv("test.csv", header = None)

# Then define preferred Columns! 
MyColumns = pd.MultiIndex.from_tuples([("Models" , ""),
                                       ("Accuracy without normalization" , ""),
                                       ("Accuracy with normalization" , "zscore"),
                                       ("Accuracy with normalization" , "minmax"),
                                       ("Accuracy with normalization" , "maxabs"),
                                       ("Accuracy with normalization" , "robust")])

# Create new DataFrame with specified Columns, after this you should pass values 
New_DataFrame = pd.DataFrame(df , columns = MyColumns)

# a loop for passing values
for item in range(len(MyColumns)):
    New_DataFrame.loc[: , MyColumns[item]] = df.iloc[: , item]
New_DataFrame.set_index(New_DataFrame.columns[0][0] , inplace=True)
New_DataFrame

Merge two data.frames (cell wise)

copy iconCopydownload iconDownload
library(tidyverse)

map2_dfc(df1, df2, ~ if_else(is.na(.x), .y, .x))

#> # A tibble: 4 × 3
#>   code      x     y
#>   <chr> <dbl> <dbl>
#> 1 A       2.3   4.1
#> 2 B       8.1   2  
#> 3 C       3.1   0.5
#> 4 D       2.6   8
-----------------------
library(dplyr)
do.call(coalesce, list(df1, df2))

  code   x   y
1    A 2.3 4.1
2    B 8.1 2.0
3    C 3.1 0.5
4    D 2.6 8.0
-----------------------
# set as data.table
lapply(list(df1, df2), \(i) setDT(i))

# custom efficient coalesce
coalesce2 <- function(...)
  {
  Reduce(function(x, y) {
    i <- which(is.na(x))
    x[i] <- y[i]
    x},
    list(...))
  }

# join
df3 <- df2[df1, on =.(code)]

# apply coalesce
df3[, `:=` (x = coalesce2(i.x, x)
            , y = coalesce2(i.y, y)
            )
    ][, c('i.x', 'i.y') := NULL
      ]
-----------------------
df1[is.na(df1)] = as.numeric(df2[is.na(df1)])
df1

print(&quot;string1&quot; or &quot;string2&quot; in string) does not give Boolean result

copy iconCopydownload iconDownload
print("Lorem" in string and "aliqua" in string )
print("Lorem" in string or "aliqua" in string )
>>> if "harsha":
...   print("hi")
...
hi
>>> if "":
...   print("hi")
...
<<No output>>
-----------------------
print("Lorem" in string and "aliqua" in string )
print("Lorem" in string or "aliqua" in string )
>>> if "harsha":
...   print("hi")
...
hi
>>> if "":
...   print("hi")
...
<<No output>>
-----------------------
print("Lorem" in string and "aliqua" in string )
print("Lorem" in string or "aliqua" in string )
>>> if "harsha":
...   print("hi")
...
hi
>>> if "":
...   print("hi")
...
<<No output>>
-----------------------
any([x in string for x in ["Lorem", "aliqua"]])
>> True
-----------------------
x and y
x or y
if (x in z) or (y in z):
    pass
-----------------------
x and y
x or y
if (x in z) or (y in z):
    pass
-----------------------
In : True and "a"
Out: 'a'

In : "a" and True
Out: True

In : True or "a"
Out: True

In : "a" or True
Out: 'a'
"Lorem" in string and "aliqua" in strign
string = "Lorem ipsum dolor sit ..."
words = ["Lorem", "ipsum", "dolor"]

# `all` checks whether everything is True
print(all(word in string for word in words))
# True

# `any` checks whether at least something is True
print(any(word in string for word in words))
# True
-----------------------
In : True and "a"
Out: 'a'

In : "a" and True
Out: True

In : True or "a"
Out: True

In : "a" or True
Out: 'a'
"Lorem" in string and "aliqua" in strign
string = "Lorem ipsum dolor sit ..."
words = ["Lorem", "ipsum", "dolor"]

# `all` checks whether everything is True
print(all(word in string for word in words))
# True

# `any` checks whether at least something is True
print(any(word in string for word in words))
# True
-----------------------
In : True and "a"
Out: 'a'

In : "a" and True
Out: True

In : True or "a"
Out: True

In : "a" or True
Out: 'a'
"Lorem" in string and "aliqua" in strign
string = "Lorem ipsum dolor sit ..."
words = ["Lorem", "ipsum", "dolor"]

# `all` checks whether everything is True
print(all(word in string for word in words))
# True

# `any` checks whether at least something is True
print(any(word in string for word in words))
# True

Ajax Requests with node server in another folder

copy iconCopydownload iconDownload
devServer: {
        hot: true,
        open: false,
        static: [
            {
                directory: path.join(__dirname, "dist")
            }],
        port: 8080,
        proxy: [{ context: ['/community', '/subscribe', '/unsubscribe'], target: 'http://localhost:3000', }],
    },
const sendHttpRequest = (method, url, data) => {
    return fetch(url, {
        method: method,
        body: JSON.stringify(data),
        headers: data ? {
            'Content-Type': 'application/json'
        } : {}
    }).then(response => {
        if (response.status >= 400) {
            return response.json().then(errResData => {
                const error = new Error('Something went wrong!');
                error.data = errResData;
                throw error;
            });
        }
        return response.json();
    });
};

const sendData = (emailInput) => {
    sendHttpRequest('POST', 'http://localhost:8080/subscribe', {
        email: emailInput
    }).then(responseData => {
        console.log(responseData);
    }).catch(err => {
        console.log(err, err.data);
    });
}
-----------------------
devServer: {
        hot: true,
        open: false,
        static: [
            {
                directory: path.join(__dirname, "dist")
            }],
        port: 8080,
        proxy: [{ context: ['/community', '/subscribe', '/unsubscribe'], target: 'http://localhost:3000', }],
    },
const sendHttpRequest = (method, url, data) => {
    return fetch(url, {
        method: method,
        body: JSON.stringify(data),
        headers: data ? {
            'Content-Type': 'application/json'
        } : {}
    }).then(response => {
        if (response.status >= 400) {
            return response.json().then(errResData => {
                const error = new Error('Something went wrong!');
                error.data = errResData;
                throw error;
            });
        }
        return response.json();
    });
};

const sendData = (emailInput) => {
    sendHttpRequest('POST', 'http://localhost:8080/subscribe', {
        email: emailInput
    }).then(responseData => {
        console.log(responseData);
    }).catch(err => {
        console.log(err, err.data);
    });
}

64-bit Equivalent to BSWAP in X86 Image Handling Routine

copy iconCopydownload iconDownload
function SwapLong(Value: Cardinal): Cardinal;
begin
  Result := Swap(Value shr 16) or (Cardinal(Swap(Value)) shl 16);
end;
function SwapLong(Value: Cardinal): Cardinal; inline;
begin
  PByte(@Result)^ := PByte(NativeUInt(@Value) + 3)^;
  PByte(NativeUInt(@Result) + 1)^ := PByte(NativeUInt(@Value) + 2)^;
  PByte(NativeUInt(@Result) + 2)^ := PByte(NativeUInt(@Value) + 1)^;
  PByte(NativeUInt(@Result) + 3)^ := PByte(@Value)^;
end;
-----------------------
function SwapLong(Value: Cardinal): Cardinal;
begin
  Result := Swap(Value shr 16) or (Cardinal(Swap(Value)) shl 16);
end;
function SwapLong(Value: Cardinal): Cardinal; inline;
begin
  PByte(@Result)^ := PByte(NativeUInt(@Value) + 3)^;
  PByte(NativeUInt(@Result) + 1)^ := PByte(NativeUInt(@Value) + 2)^;
  PByte(NativeUInt(@Result) + 2)^ := PByte(NativeUInt(@Value) + 1)^;
  PByte(NativeUInt(@Result) + 3)^ := PByte(@Value)^;
end;
-----------------------
function SwapLong(Value: Cardinal): Cardinal;
{$IFDEF ASSEMBLER}
{$IFDEF CPUX86}
asm
  bswap eax
end;
{$ENDIF CPUX86}

{$IFDEF CPUX64}
asm
  mov eax, ecx
  bswap eax
end;
{$ENDIF CPUX64}
{$ELSE}
begin
  // pascal version
end;
{$ENDIF}

Responsive HTML Table While Avoiding Display Block

copy iconCopydownload iconDownload
:root {
  --global-title-color: black;
  --global-content-background-color: lightgreen;
  --global-background-color: lightblue;
  --global-border-color: red;
  --global-border-radius: 5px;
  --global-border-width-1: 1px;
  --global-font-size-1: 20px;
  --global-font-weight-bold: bold;
  --global-space-fixed-2: 5px;
  --global-space-fixed-3: 10px;
}

.container {
  display: block;
  background: yellow;
  resize: horizontal;
  overflow: auto;
  min-height: 150px;
}

table {
  color: var(--global-title-color);
  background-color: var(--global-content-background-color);
  border-collapse: separate;
  border-color: var(--global-title-color);
  border-style: solid;
  border-radius: var(--global-border-radius);
  border-width: 0 var(--global-border-width-1) var(--global-border-width-1)
    var(--global-border-width-1);
  border-spacing: 0;
  overflow: auto;
  width: 100%;

  thead {
    th {
      color: var(--global-background-color);
      background-color: var(--global-title-color);
      font-weight: var(--global-font-weight-bold);
      font-size: var(--global-font-size-1);
      padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
      vertical-align: bottom;
    }

    th:first-child {
      border-top-left-radius: var(--global-border-radius);
    }

    th:last-child {
      border-top-right-radius: var(--global-border-radius);
    }
  }

  tbody {
    td {
      border-top: var(--global-border-width-1) solid var(--global-border-color);
      min-width: 100px;
      padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
      vertical-align: top;
    }

    tr:nth-child(2n) {
      background-color: var(--global-background-color);
    }

    tr:last-child {
      td:first-child {
        border-bottom-left-radius: var(--global-border-radius);
      }

      td:last-child {
        border-bottom-right-radius: var(--global-border-radius);
      }
    }
  }
}
<div class="container">

<table>
<thead>
<tr>
<th>SDK</th>
<th>Default namespaces</th>
</tr>
</thead>
<tbody>
<tr>
<td>Microsoft.NET.Sdk</td>
<td><code class="language-inline-text">System.Collections.Generic</code></td>
</tr>
<tr>
<td>Microsoft.NET.Sdk.Web</td>
<td><code class="language-inline-text">System.Net.Http.Json</code></td>
</tr>

</tbody>
</table>
  
</div>
-----------------------
:root {
  --global-title-color: black;
  --global-content-background-color: lightgreen;
  --global-background-color: lightblue;
  --global-border-color: red;
  --global-border-radius: 5px;
  --global-border-width-1: 1px;
  --global-font-size-1: 20px;
  --global-font-weight-bold: bold;
  --global-space-fixed-2: 5px;
  --global-space-fixed-3: 10px;
}

.container {
  display: block;
  background: yellow;
  resize: horizontal;
  overflow: auto;
  min-height: 150px;
}

table {
  color: var(--global-title-color);
  background-color: var(--global-content-background-color);
  border-collapse: separate;
  border-color: var(--global-title-color);
  border-style: solid;
  border-radius: var(--global-border-radius);
  border-width: 0 var(--global-border-width-1) var(--global-border-width-1)
    var(--global-border-width-1);
  border-spacing: 0;
  overflow: auto;
  width: 100%;

  thead {
    th {
      color: var(--global-background-color);
      background-color: var(--global-title-color);
      font-weight: var(--global-font-weight-bold);
      font-size: var(--global-font-size-1);
      padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
      vertical-align: bottom;
    }

    th:first-child {
      border-top-left-radius: var(--global-border-radius);
    }

    th:last-child {
      border-top-right-radius: var(--global-border-radius);
    }
  }

  tbody {
    td {
      border-top: var(--global-border-width-1) solid var(--global-border-color);
      min-width: 100px;
      padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
      vertical-align: top;
    }

    tr:nth-child(2n) {
      background-color: var(--global-background-color);
    }

    tr:last-child {
      td:first-child {
        border-bottom-left-radius: var(--global-border-radius);
      }

      td:last-child {
        border-bottom-right-radius: var(--global-border-radius);
      }
    }
  }
}
<div class="container">

<table>
<thead>
<tr>
<th>SDK</th>
<th>Default namespaces</th>
</tr>
</thead>
<tbody>
<tr>
<td>Microsoft.NET.Sdk</td>
<td><code class="language-inline-text">System.Collections.Generic</code></td>
</tr>
<tr>
<td>Microsoft.NET.Sdk.Web</td>
<td><code class="language-inline-text">System.Net.Http.Json</code></td>
</tr>

</tbody>
</table>
  
</div>
-----------------------
th {
  width: 0.1%;
  white-space: nowrap;
}
:root {
  --global-title-color: black;
  --global-content-background-color: lightgreen;
  --global-background-color: lightblue;
  --global-border-color: red;
  --global-border-radius: 5px;
  --global-border-width-1: 1px;
  --global-font-size-1: 20px;
  --global-font-weight-bold: bold;
  --global-space-fixed-2: 5px;
  --global-space-fixed-3: 10px;
}

.container {
  display: block;
  background: yellow;
  resize: horizontal;
  overflow: hidden;
  min-height: 150px;
}

table {
  display: block;
  color: var(--global-title-color);
  background-color: var(--global-content-background-color);
  border-collapse: separate;
  border-color: var(--global-title-color);
  border-style: solid;
  border-radius: var(--global-border-radius);
  border-width: 0 var(--global-border-width-1) var(--global-border-width-1) var(--global-border-width-1);
  border-spacing: 0;
  overflow: auto;
}

th {
  width: 0.1%;
  white-space: nowrap;
}

th {
  color: var(--global-background-color);
  background-color: var(--global-title-color);
  font-weight: var(--global-font-weight-bold);
  font-size: var(--global-font-size-1);
  padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
  vertical-align: bottom;
  white-space: nowrap;
}

th:first-child {
  border-top-left-radius: var(--global-border-radius);
}

th:last-child {
  border-top-right-radius: var(--global-border-radius);
}

td {
  border-top: var(--global-border-width-1) solid var(--global-border-color);
  /* min-width: 100px; /* /* changed */
  padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
  vertical-align: top;
}

tr:nth-child(2n) {
  background-color: var(--global-background-color);
}

tr:last-child td:first-child {
  border-bottom-left-radius: var(--global-border-radius);
}

tr:last-child td:last-child {
  border-bottom-right-radius: var(--global-border-radius);
}
<div class="container">
      <p>
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facilis
        voluptatum inventore iure blanditiis ab ipsum nostrum repellat cum
        tempore. Quas harum dolores totam voluptatem deserunt et praesentium
        nihil placeat. Voluptas.
      </p>
      <table>
        <thead>
          <tr>
            <th>SDK</th>
            <th>Default namespaces</th>
            <th>Values</th>
            <th>Default</th>
            <th>Other stuff</th>
            <th>#</th>
            <th>SDK</th>
            <th>Namespaces</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Microsoft.NET.Sdk</td>
            <td>
              <code class="language-inline-text"
                >System.Collections.Generic</code
              >
            </td>
            <td>Values</td>
            <td>
              <code class="language-inline-text">Generic</code>
            </td>
            <td>Microsoft.NET.Sdk</td>
            <td>
              <code class="language-inline-text">00</code>
            </td>
            <td>NET.Sdk</td>
            <td>
              <code class="language-inline-text"
                >System.Collections.Generic</code
              >
            </td>
          </tr>
          <tr>
            <td>Microsoft.NET.Sdk.Web</td>
            <td>
              <code class="language-inline-text">System.Net.Http.Json</code>
            </td>
            <td>Web</td>
            <td>
              <code class="language-inline-text">System.Net.Http.Json</code>
            </td>
            <td>Microsoft.NET.Sdk.Web</td>
            <td>
              <code class="language-inline-text">33</code>
            </td>
            <td>Sdk.Web</td>
            <td>
              <code class="language-inline-text">Http.Json</code>
            </td>
          </tr>
        </tbody>
      </table>
      <p>
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facilis
        voluptatum inventore iure blanditiis ab ipsum nostrum repellat cum
        tempore. Quas harum dolores totam voluptatem deserunt et praesentium
        nihil placeat. Voluptas.
      </p>
    </div>
-----------------------
th {
  width: 0.1%;
  white-space: nowrap;
}
:root {
  --global-title-color: black;
  --global-content-background-color: lightgreen;
  --global-background-color: lightblue;
  --global-border-color: red;
  --global-border-radius: 5px;
  --global-border-width-1: 1px;
  --global-font-size-1: 20px;
  --global-font-weight-bold: bold;
  --global-space-fixed-2: 5px;
  --global-space-fixed-3: 10px;
}

.container {
  display: block;
  background: yellow;
  resize: horizontal;
  overflow: hidden;
  min-height: 150px;
}

table {
  display: block;
  color: var(--global-title-color);
  background-color: var(--global-content-background-color);
  border-collapse: separate;
  border-color: var(--global-title-color);
  border-style: solid;
  border-radius: var(--global-border-radius);
  border-width: 0 var(--global-border-width-1) var(--global-border-width-1) var(--global-border-width-1);
  border-spacing: 0;
  overflow: auto;
}

th {
  width: 0.1%;
  white-space: nowrap;
}

th {
  color: var(--global-background-color);
  background-color: var(--global-title-color);
  font-weight: var(--global-font-weight-bold);
  font-size: var(--global-font-size-1);
  padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
  vertical-align: bottom;
  white-space: nowrap;
}

th:first-child {
  border-top-left-radius: var(--global-border-radius);
}

th:last-child {
  border-top-right-radius: var(--global-border-radius);
}

td {
  border-top: var(--global-border-width-1) solid var(--global-border-color);
  /* min-width: 100px; /* /* changed */
  padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
  vertical-align: top;
}

tr:nth-child(2n) {
  background-color: var(--global-background-color);
}

tr:last-child td:first-child {
  border-bottom-left-radius: var(--global-border-radius);
}

tr:last-child td:last-child {
  border-bottom-right-radius: var(--global-border-radius);
}
<div class="container">
      <p>
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facilis
        voluptatum inventore iure blanditiis ab ipsum nostrum repellat cum
        tempore. Quas harum dolores totam voluptatem deserunt et praesentium
        nihil placeat. Voluptas.
      </p>
      <table>
        <thead>
          <tr>
            <th>SDK</th>
            <th>Default namespaces</th>
            <th>Values</th>
            <th>Default</th>
            <th>Other stuff</th>
            <th>#</th>
            <th>SDK</th>
            <th>Namespaces</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Microsoft.NET.Sdk</td>
            <td>
              <code class="language-inline-text"
                >System.Collections.Generic</code
              >
            </td>
            <td>Values</td>
            <td>
              <code class="language-inline-text">Generic</code>
            </td>
            <td>Microsoft.NET.Sdk</td>
            <td>
              <code class="language-inline-text">00</code>
            </td>
            <td>NET.Sdk</td>
            <td>
              <code class="language-inline-text"
                >System.Collections.Generic</code
              >
            </td>
          </tr>
          <tr>
            <td>Microsoft.NET.Sdk.Web</td>
            <td>
              <code class="language-inline-text">System.Net.Http.Json</code>
            </td>
            <td>Web</td>
            <td>
              <code class="language-inline-text">System.Net.Http.Json</code>
            </td>
            <td>Microsoft.NET.Sdk.Web</td>
            <td>
              <code class="language-inline-text">33</code>
            </td>
            <td>Sdk.Web</td>
            <td>
              <code class="language-inline-text">Http.Json</code>
            </td>
          </tr>
        </tbody>
      </table>
      <p>
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facilis
        voluptatum inventore iure blanditiis ab ipsum nostrum repellat cum
        tempore. Quas harum dolores totam voluptatem deserunt et praesentium
        nihil placeat. Voluptas.
      </p>
    </div>
-----------------------
th {
  width: 0.1%;
  white-space: nowrap;
}
:root {
  --global-title-color: black;
  --global-content-background-color: lightgreen;
  --global-background-color: lightblue;
  --global-border-color: red;
  --global-border-radius: 5px;
  --global-border-width-1: 1px;
  --global-font-size-1: 20px;
  --global-font-weight-bold: bold;
  --global-space-fixed-2: 5px;
  --global-space-fixed-3: 10px;
}

.container {
  display: block;
  background: yellow;
  resize: horizontal;
  overflow: hidden;
  min-height: 150px;
}

table {
  display: block;
  color: var(--global-title-color);
  background-color: var(--global-content-background-color);
  border-collapse: separate;
  border-color: var(--global-title-color);
  border-style: solid;
  border-radius: var(--global-border-radius);
  border-width: 0 var(--global-border-width-1) var(--global-border-width-1) var(--global-border-width-1);
  border-spacing: 0;
  overflow: auto;
}

th {
  width: 0.1%;
  white-space: nowrap;
}

th {
  color: var(--global-background-color);
  background-color: var(--global-title-color);
  font-weight: var(--global-font-weight-bold);
  font-size: var(--global-font-size-1);
  padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
  vertical-align: bottom;
  white-space: nowrap;
}

th:first-child {
  border-top-left-radius: var(--global-border-radius);
}

th:last-child {
  border-top-right-radius: var(--global-border-radius);
}

td {
  border-top: var(--global-border-width-1) solid var(--global-border-color);
  /* min-width: 100px; /* /* changed */
  padding: var(--global-space-fixed-2) var(--global-space-fixed-3);
  vertical-align: top;
}

tr:nth-child(2n) {
  background-color: var(--global-background-color);
}

tr:last-child td:first-child {
  border-bottom-left-radius: var(--global-border-radius);
}

tr:last-child td:last-child {
  border-bottom-right-radius: var(--global-border-radius);
}
<div class="container">
      <p>
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facilis
        voluptatum inventore iure blanditiis ab ipsum nostrum repellat cum
        tempore. Quas harum dolores totam voluptatem deserunt et praesentium
        nihil placeat. Voluptas.
      </p>
      <table>
        <thead>
          <tr>
            <th>SDK</th>
            <th>Default namespaces</th>
            <th>Values</th>
            <th>Default</th>
            <th>Other stuff</th>
            <th>#</th>
            <th>SDK</th>
            <th>Namespaces</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Microsoft.NET.Sdk</td>
            <td>
              <code class="language-inline-text"
                >System.Collections.Generic</code
              >
            </td>
            <td>Values</td>
            <td>
              <code class="language-inline-text">Generic</code>
            </td>
            <td>Microsoft.NET.Sdk</td>
            <td>
              <code class="language-inline-text">00</code>
            </td>
            <td>NET.Sdk</td>
            <td>
              <code class="language-inline-text"
                >System.Collections.Generic</code
              >
            </td>
          </tr>
          <tr>
            <td>Microsoft.NET.Sdk.Web</td>
            <td>
              <code class="language-inline-text">System.Net.Http.Json</code>
            </td>
            <td>Web</td>
            <td>
              <code class="language-inline-text">System.Net.Http.Json</code>
            </td>
            <td>Microsoft.NET.Sdk.Web</td>
            <td>
              <code class="language-inline-text">33</code>
            </td>
            <td>Sdk.Web</td>
            <td>
              <code class="language-inline-text">Http.Json</code>
            </td>
          </tr>
        </tbody>
      </table>
      <p>
        Lorem ipsum dolor sit, amet consectetur adipisicing elit. Facilis
        voluptatum inventore iure blanditiis ab ipsum nostrum repellat cum
        tempore. Quas harum dolores totam voluptatem deserunt et praesentium
        nihil placeat. Voluptas.
      </p>
    </div>

Tensorflow &quot;Transformer model for language understanding&quot; with another Dataset?

copy iconCopydownload iconDownload
import collections
import logging
import os
import pathlib
import re
import string
import sys
import time
import numpy as np
#import matplotlib.pyplot as plt

import tensorflow_datasets as tfds
import tensorflow_text as text
import tensorflow as tf
from tensorflow_text.tools.wordpiece_vocab import bert_vocab_from_dataset as bert_vocab



examples, metadata = tfds.load('wmt14_translate/de-en', with_info=True,
                               as_supervised=True)
train_examples, val_examples = examples['train'], examples['validation']

for de_examples, en_examples in train_examples.batch(3).take(1):
  for pt in de_examples.numpy():
    print(pt.decode('utf-8'))

  print()

  for en in en_examples.numpy():
    print(en.decode('utf-8'))

train_en = train_examples.map(lambda de, en: en)
train_de = train_examples.map(lambda de, en: de)

bert_tokenizer_params=dict(lower_case=True)
reserved_tokens=["[PAD]", "[UNK]", "[START]", "[END]"]

bert_vocab_args = dict(
    # The target vocabulary size
    vocab_size = 8000,
    # Reserved tokens that must be included in the vocabulary
    reserved_tokens=reserved_tokens,
    # Arguments for `text.BertTokenizer`
    bert_tokenizer_params=bert_tokenizer_params,
    # Arguments for `wordpiece_vocab.wordpiece_tokenizer_learner_lib.learn`
    learn_params={},
)

de_vocab = bert_vocab.bert_vocab_from_dataset(
    train_de.batch(1000).prefetch(2),
    **bert_vocab_args
)

print(de_vocab[:10])
print(de_vocab[100:110])
print(de_vocab[1000:1010])
print(de_vocab[-10:])

def write_vocab_file(filepath, vocab):
  with open(filepath, 'w') as f:
    for token in vocab:
      print(token, file=f)

write_vocab_file('de_vocab.txt', de_vocab)

en_vocab = bert_vocab.bert_vocab_from_dataset(
    train_en.batch(1000).prefetch(2),
    **bert_vocab_args
)

print(en_vocab[:10])
print(en_vocab[100:110])
print(en_vocab[1000:1010])
print(en_vocab[-10:])

write_vocab_file('en_vocab.txt', en_vocab)

de_tokenizer = text.BertTokenizer('de_vocab.txt', **bert_tokenizer_params)
en_tokenizer = text.BertTokenizer('en_vocab.txt', **bert_tokenizer_params)

# Tokenize the examples -> (batch, word, word-piece)
token_batch = en_tokenizer.tokenize(en_examples)
# Merge the word and word-piece axes -> (batch, tokens)
token_batch = token_batch.merge_dims(-2,-1)

for ex in token_batch.to_list():
  print(ex)

# Lookup each token id in the vocabulary.
txt_tokens = tf.gather(en_vocab, token_batch)
# Join with spaces.
tf.strings.reduce_join(txt_tokens, separator=' ', axis=-1)

words = en_tokenizer.detokenize(token_batch)
tf.strings.reduce_join(words, separator=' ', axis=-1)

START = tf.argmax(tf.constant(reserved_tokens) == "[START]")
END = tf.argmax(tf.constant(reserved_tokens) == "[END]")

def add_start_end(ragged):
  count = ragged.bounding_shape()[0]
  starts = tf.fill([count,1], START)
  ends = tf.fill([count,1], END)
  return tf.concat([starts, ragged, ends], axis=1)

words = en_tokenizer.detokenize(add_start_end(token_batch))
tf.strings.reduce_join(words, separator=' ', axis=-1)

def cleanup_text(reserved_tokens, token_txt):
  # Drop the reserved tokens, except for "[UNK]".
  bad_tokens = [re.escape(tok) for tok in reserved_tokens if tok != "[UNK]"]
  bad_token_re = "|".join(bad_tokens)

  bad_cells = tf.strings.regex_full_match(token_txt, bad_token_re)
  result = tf.ragged.boolean_mask(token_txt, ~bad_cells)

  # Join them into strings.
  result = tf.strings.reduce_join(result, separator=' ', axis=-1)

  return result

token_batch = en_tokenizer.tokenize(en_examples).merge_dims(-2,-1)
words = en_tokenizer.detokenize(token_batch)

cleanup_text(reserved_tokens, words).numpy()

class CustomTokenizer(tf.Module):
  def __init__(self, reserved_tokens, vocab_path):
    self.tokenizer = text.BertTokenizer(vocab_path, lower_case=True)
    self._reserved_tokens = reserved_tokens
    self._vocab_path = tf.saved_model.Asset(vocab_path)

    vocab = pathlib.Path(vocab_path).read_text().splitlines()
    self.vocab = tf.Variable(vocab)

    ## Create the signatures for export:

    # Include a tokenize signature for a batch of strings.
    self.tokenize.get_concrete_function(
        tf.TensorSpec(shape=[None], dtype=tf.string))

    # Include `detokenize` and `lookup` signatures for:
    #   * `Tensors` with shapes [tokens] and [batch, tokens]
    #   * `RaggedTensors` with shape [batch, tokens]
    self.detokenize.get_concrete_function(
        tf.TensorSpec(shape=[None, None], dtype=tf.int64))
    self.detokenize.get_concrete_function(
          tf.RaggedTensorSpec(shape=[None, None], dtype=tf.int64))

    self.lookup.get_concrete_function(
        tf.TensorSpec(shape=[None, None], dtype=tf.int64))
    self.lookup.get_concrete_function(
          tf.RaggedTensorSpec(shape=[None, None], dtype=tf.int64))

    # These `get_*` methods take no arguments
    self.get_vocab_size.get_concrete_function()
    self.get_vocab_path.get_concrete_function()
    self.get_reserved_tokens.get_concrete_function()

  @tf.function
  def tokenize(self, strings):
    enc = self.tokenizer.tokenize(strings)
    # Merge the `word` and `word-piece` axes.
    enc = enc.merge_dims(-2,-1)
    enc = add_start_end(enc)
    return enc

  @tf.function
  def detokenize(self, tokenized):
    words = self.tokenizer.detokenize(tokenized)
    return cleanup_text(self._reserved_tokens, words)

  @tf.function
  def lookup(self, token_ids):
    return tf.gather(self.vocab, token_ids)

  @tf.function
  def get_vocab_size(self):
    return tf.shape(self.vocab)[0]

  @tf.function
  def get_vocab_path(self):
    return self._vocab_path

  @tf.function
  def get_reserved_tokens(self):
    return tf.constant(self._reserved_tokens)

tokenizers = tf.Module()
tokenizers.pt = CustomTokenizer(reserved_tokens, 'de_vocab.txt')
tokenizers.en = CustomTokenizer(reserved_tokens, 'en_vocab.txt')

model_name = 'ted_hrlr_translate_de_en_converter'
tf.saved_model.save(tokenizers, model_name)
-----------------------
import transformers 
import tensorflow as tf 
from tensorflow import keras

tokenizer = transformers.BertTokenizer.from_pretrained("bert-base-uncased")

tokenizer(["hello world", "this is me", "hello again"], return_tensors="tf", padding=True, truncation=True)
{'input_ids': <tf.Tensor: shape=(3, 5), dtype=int32, numpy=
array([[ 101, 7592, 2088,  102,    0],
       [ 101, 2023, 2003, 2033,  102],
       [ 101, 7592, 2153,  102,    0]], dtype=int32)>, 'token_type_ids': <tf.Tensor: shape=(3, 5), dtype=int32, numpy=
array([[0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=int32)>, 'attention_mask': <tf.Tensor: shape=(3, 5), dtype=int32, numpy=
array([[1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 0]], dtype=int32)>}
-----------------------
import transformers 
import tensorflow as tf 
from tensorflow import keras

tokenizer = transformers.BertTokenizer.from_pretrained("bert-base-uncased")

tokenizer(["hello world", "this is me", "hello again"], return_tensors="tf", padding=True, truncation=True)
{'input_ids': <tf.Tensor: shape=(3, 5), dtype=int32, numpy=
array([[ 101, 7592, 2088,  102,    0],
       [ 101, 2023, 2003, 2033,  102],
       [ 101, 7592, 2153,  102,    0]], dtype=int32)>, 'token_type_ids': <tf.Tensor: shape=(3, 5), dtype=int32, numpy=
array([[0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=int32)>, 'attention_mask': <tf.Tensor: shape=(3, 5), dtype=int32, numpy=
array([[1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1],
       [1, 1, 1, 1, 0]], dtype=int32)>}

How to adjust css print and apply page break for every tab in window.print?

copy iconCopydownload iconDownload
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content > .tab-pane {
    display: block !important;
  }
  .tab-content > .fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
$('#downloadPdf').click(function () {
  window.print();
});
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content>.tab-pane {
    display: block !important;
  }
  .tab-content>.fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<div class="container">
  <h2>Dynamic Tabs</h2>
  <ul class="nav nav-tabs" id="tabs">
    <li class="active">
      <a data-toggle="tab" href="#homepage">Terms & Condition</a>
    </li>
    <li><a data-toggle="tab" href="#home">Info</a></li>
    <li><a data-toggle="tab" href="#info">Form</a></li>
    <li><a data-toggle="tab" href="#form">Menu 3</a></li>
  </ul>

  <div class="tab-content">
    <div id="homepage" class="tab-pane fade in active">
      <h3>Terms and Conditions</h3>
      <span style="font-size: 80%"><i>Please read the terms and condition first</i></span
          >
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            <input type="checkbox" id="reg" /> Please tick this if u have read
            and understand everything
          </p>
        </div>
        <div id="home" class="tab-pane fade">
          <h3>Menu 1</h3>
          <p>
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
            nisi ut aliquip ex ea commodo consequat.
          </p>
        </div>
        <div id="info" class="tab-pane fade">
          <h3>Menu 2</h3>
          <div class="form-row">
            <div class="col-md-12">
              <input type="text" class="form-control" placeholder="City" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="State" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="Zip" />
            </div>
          </div>
        </div>
        <div id="form" class="tab-pane fade">
          <h3>Menu 3</h3>
          <p>
            Eaque ipsa quae ab illo inventore veritatis et quasi architecto
            beatae vitae dicta sunt explicabo.
          </p>
          <br />
        </div>
      </div>
    </div>
    <hr />
    <div>
      <p>
        <button
          type="button"
          id="downloadPdf"
          class="btn btn-warning"
          data-toggle="tooltip"
          data-placement="top"
          title="Download"
        >
          Download
        </button>
      </p>
    </div>
-----------------------
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content > .tab-pane {
    display: block !important;
  }
  .tab-content > .fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
$('#downloadPdf').click(function () {
  window.print();
});
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content>.tab-pane {
    display: block !important;
  }
  .tab-content>.fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<div class="container">
  <h2>Dynamic Tabs</h2>
  <ul class="nav nav-tabs" id="tabs">
    <li class="active">
      <a data-toggle="tab" href="#homepage">Terms & Condition</a>
    </li>
    <li><a data-toggle="tab" href="#home">Info</a></li>
    <li><a data-toggle="tab" href="#info">Form</a></li>
    <li><a data-toggle="tab" href="#form">Menu 3</a></li>
  </ul>

  <div class="tab-content">
    <div id="homepage" class="tab-pane fade in active">
      <h3>Terms and Conditions</h3>
      <span style="font-size: 80%"><i>Please read the terms and condition first</i></span
          >
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            <input type="checkbox" id="reg" /> Please tick this if u have read
            and understand everything
          </p>
        </div>
        <div id="home" class="tab-pane fade">
          <h3>Menu 1</h3>
          <p>
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
            nisi ut aliquip ex ea commodo consequat.
          </p>
        </div>
        <div id="info" class="tab-pane fade">
          <h3>Menu 2</h3>
          <div class="form-row">
            <div class="col-md-12">
              <input type="text" class="form-control" placeholder="City" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="State" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="Zip" />
            </div>
          </div>
        </div>
        <div id="form" class="tab-pane fade">
          <h3>Menu 3</h3>
          <p>
            Eaque ipsa quae ab illo inventore veritatis et quasi architecto
            beatae vitae dicta sunt explicabo.
          </p>
          <br />
        </div>
      </div>
    </div>
    <hr />
    <div>
      <p>
        <button
          type="button"
          id="downloadPdf"
          class="btn btn-warning"
          data-toggle="tooltip"
          data-placement="top"
          title="Download"
        >
          Download
        </button>
      </p>
    </div>
-----------------------
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content > .tab-pane {
    display: block !important;
  }
  .tab-content > .fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
$('#downloadPdf').click(function () {
  window.print();
});
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content>.tab-pane {
    display: block !important;
  }
  .tab-content>.fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<div class="container">
  <h2>Dynamic Tabs</h2>
  <ul class="nav nav-tabs" id="tabs">
    <li class="active">
      <a data-toggle="tab" href="#homepage">Terms & Condition</a>
    </li>
    <li><a data-toggle="tab" href="#home">Info</a></li>
    <li><a data-toggle="tab" href="#info">Form</a></li>
    <li><a data-toggle="tab" href="#form">Menu 3</a></li>
  </ul>

  <div class="tab-content">
    <div id="homepage" class="tab-pane fade in active">
      <h3>Terms and Conditions</h3>
      <span style="font-size: 80%"><i>Please read the terms and condition first</i></span
          >
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            <input type="checkbox" id="reg" /> Please tick this if u have read
            and understand everything
          </p>
        </div>
        <div id="home" class="tab-pane fade">
          <h3>Menu 1</h3>
          <p>
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
            nisi ut aliquip ex ea commodo consequat.
          </p>
        </div>
        <div id="info" class="tab-pane fade">
          <h3>Menu 2</h3>
          <div class="form-row">
            <div class="col-md-12">
              <input type="text" class="form-control" placeholder="City" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="State" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="Zip" />
            </div>
          </div>
        </div>
        <div id="form" class="tab-pane fade">
          <h3>Menu 3</h3>
          <p>
            Eaque ipsa quae ab illo inventore veritatis et quasi architecto
            beatae vitae dicta sunt explicabo.
          </p>
          <br />
        </div>
      </div>
    </div>
    <hr />
    <div>
      <p>
        <button
          type="button"
          id="downloadPdf"
          class="btn btn-warning"
          data-toggle="tooltip"
          data-placement="top"
          title="Download"
        >
          Download
        </button>
      </p>
    </div>
-----------------------
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content > .tab-pane {
    display: block !important;
  }
  .tab-content > .fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
$('#downloadPdf').click(function () {
  window.print();
});
@media print {
  .nav-tabs {
    display: none !important;
  }
  .tab-content>.tab-pane {
    display: block !important;
  }
  .tab-content>.fade {
    opacity: 1;
  }
  #downloadPdf {
    display: none;
  }
  /* New lines */
  #home,
  #info,
  #form {
    page-break-before: always;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

<div class="container">
  <h2>Dynamic Tabs</h2>
  <ul class="nav nav-tabs" id="tabs">
    <li class="active">
      <a data-toggle="tab" href="#homepage">Terms & Condition</a>
    </li>
    <li><a data-toggle="tab" href="#home">Info</a></li>
    <li><a data-toggle="tab" href="#info">Form</a></li>
    <li><a data-toggle="tab" href="#form">Menu 3</a></li>
  </ul>

  <div class="tab-content">
    <div id="homepage" class="tab-pane fade in active">
      <h3>Terms and Conditions</h3>
      <span style="font-size: 80%"><i>Please read the terms and condition first</i></span
          >
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <p>
            <input type="checkbox" id="reg" /> Please tick this if u have read
            and understand everything
          </p>
        </div>
        <div id="home" class="tab-pane fade">
          <h3>Menu 1</h3>
          <p>
            Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
            nisi ut aliquip ex ea commodo consequat.
          </p>
        </div>
        <div id="info" class="tab-pane fade">
          <h3>Menu 2</h3>
          <div class="form-row">
            <div class="col-md-12">
              <input type="text" class="form-control" placeholder="City" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="State" />
            </div>
            <div class="col-md-6">
              <input type="text" class="form-control" placeholder="Zip" />
            </div>
          </div>
        </div>
        <div id="form" class="tab-pane fade">
          <h3>Menu 3</h3>
          <p>
            Eaque ipsa quae ab illo inventore veritatis et quasi architecto
            beatae vitae dicta sunt explicabo.
          </p>
          <br />
        </div>
      </div>
    </div>
    <hr />
    <div>
      <p>
        <button
          type="button"
          id="downloadPdf"
          class="btn btn-warning"
          data-toggle="tooltip"
          data-placement="top"
          title="Download"
        >
          Download
        </button>
      </p>
    </div>

Community Discussions

Trending Discussions on ET
  • When replacing medians in an unknown category get NA in R
  • Is this a bug in ruby Regexp? How to guard against &quot;infinite loop&quot; from regex match without using Timeout?
  • Creating nested columns in python dataframe
  • Merge two data.frames (cell wise)
  • print(&quot;string1&quot; or &quot;string2&quot; in string) does not give Boolean result
  • Why does String.Equals with InvariantCultureIgnoreCase behave different in .net 4.7.2 and .net 5?
  • Ajax Requests with node server in another folder
  • 64-bit Equivalent to BSWAP in X86 Image Handling Routine
  • Responsive HTML Table While Avoiding Display Block
  • Tensorflow &quot;Transformer model for language understanding&quot; with another Dataset?
Trending Discussions on ET

QUESTION

When replacing medians in an unknown category get NA in R

Asked 2022-Apr-09 at 15:25

I have two datasets

d1=structure(list(et = c("s", "s"), gg = c("d", "d"), hj = c("f", 
"f"), ggh = c("h", "h"), wer = c(23L, 45L)), class = "data.frame", row.names = c(NA, 
-2L))

and

d2=structure(list(et = c("s", "s"), gg = c("d", "d"), hj = c("f", 
"f"), ggh = c("h", "f"), wer = c(3L, 7L)), class = "data.frame", row.names = c(NA, 
-2L))

I perform changing value according to principle that if in the dataset d2 the value wer for the same categories with d1, less or greater than the median from d1 for this category on 1, then in d2 put the value of the median in this category.

To be more clear what i want , for this categoty from d1

et  gg  hj  ggh (this categorical vars)
s   d   f   h

median by wer=34

d2 has same category s d f h where wer=3, so 3<34 so i must change this value on 34, but also d2 has category s d f f which is absent in d1, so we left value for unknown category in d1.

Now i use code

library(dplyr)

d1 %>% 
  group_by(across(-wer)) %>% 
  summarise(wer = median(wer), .groups = "drop") %>% 
  right_join(d2, by = c("et", "gg", "hj", "ggh"), suffix = c("", ".y")) %>% 
  mutate(wer = ifelse(wer >= wer.y, wer, wer.y), .keep = "unused")

it does what I need, however, for an unknown category in d1, it puts down NA result

  et    gg    hj    ggh     wer
  <chr> <chr> <chr> <chr> <dbl>
1 s     d     f     h        34
2 s     d     f     f        NA

But instead must be real value for this category from d2 like this

  et    gg    hj    ggh     wer
  <chr> <chr> <chr> <chr> <dbl>
1 s     d     f     h        34
2 s     d     f     f        7

How can i fix it ? Thank you for your help

ANSWER

Answered 2022-Apr-09 at 15:25

Comparison operators returns NA when there is an NA

> 7 > NA
[1] NA

In the code, we just need to do the correction for NA by adding a condition using is.na

library(dplyr)
d1 %>% 
   group_by(across(-wer)) %>% 
   summarise(wer = median(wer), .groups = "drop") %>% 
   right_join(d2, by = c("et", "gg", "hj", "ggh"), suffix = c("", ".y")) %>% 
   mutate(wer = ifelse(wer >= wer.y & !is.na(wer), wer, wer.y), .keep = "unused")
# A tibble: 2 × 5
  et    gg    hj    ggh     wer
  <chr> <chr> <chr> <chr> <dbl>
1 s     d     f     h        34
2 s     d     f     f         7

Source https://stackoverflow.com/questions/71807067

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install ET

You can download it from GitHub.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Reuse Pre-built Kits with ET
Try Top Libraries by egametang
Compare Game Engine Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.